diff --git a/.gulp/regeneration.iced b/.gulp/regeneration.iced index 0a0342cf7..bf0216cb2 100644 --- a/.gulp/regeneration.iced +++ b/.gulp/regeneration.iced @@ -18,9 +18,17 @@ task 'regenerate', 'regenerate samples', (done) -> ShellString(stdout).to(path.join(outputFolder, "stdout.txt")) ShellString(stderr).to(path.join(outputFolder, "stderr.txt")) - # sanitize generated files (source maps and shell stuff may contain file:/// paths) + # sanitize generated files + + ## clear out generated sources; it's language owner's job to ensure quality of the content, + ## we just check for existence and basic structure to detect core problems (URI resolution, file emitting, ...) (find path.join(each.path, "..")) - .filter((file) -> file.match(/.(map|txt)$/)) + .filter((file) -> file.match(/\.(cs|go|java|js|ts|php|py|rb)$/)) + .forEach((file) -> "SRC".to(file)) + + ## source maps and shell stuff (contains platform/folder dependent stuff) + (find path.join(each.path, "..")) + .filter((file) -> file.match(/\.(map|txt)$/)) .forEach((file) -> sed "-i", /\bfile:\/\/[^\s]*\/autorest[^\/\\]*/g, "", file # blame locations sed "-i", /\sat .*/g, "at ...", file # exception stack traces @@ -32,7 +40,7 @@ task 'regenerate', 'regenerate samples', (done) -> ) (find path.join(each.path, "..")) - .filter((file) -> file.match(/.(yaml)$/)) + .filter((file) -> file.match(/\.(yaml)$/)) .forEach((file) -> sed "-i", /.*autorest[a-zA-Z0-9]*.src.*/ig, "", file # source file names ) diff --git a/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs b/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs index 5993f0818..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs +++ b/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs @@ -1,406 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - /// - /// This is a sample server Petstore server. You can find out more about - /// Swagger at <a - /// href="http://swagger.io">http://swagger.io</a> or on - /// irc.freenode.net, #swagger. For this sample, you can use the api key - /// "special-key" to test the authorization filters - /// - public partial interface ISwaggerPetstore : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Fake endpoint to test byte array in body parameter for adding a new - /// pet to the store - /// - /// - /// Pet object in the form of byte array - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task AddPetUsingByteArrayWithHttpMessagesAsync(string body = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Add a new pet to the store - /// - /// - /// Adds a new pet to the store. You may receive an HTTP invalid input - /// if your pet is invalid. - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task AddPetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Update an existing pet - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task UpdatePetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma seperated strings - /// - /// - /// Status values that need to be considered for filter - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task>> FindPetsByStatusWithHttpMessagesAsync(IList status = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Finds Pets by tags - /// - /// - /// Muliple tags can be provided with comma seperated strings. Use - /// tag1, tag2, tag3 for testing. - /// - /// - /// Tags to filter by - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will - /// simulate API error conditions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> FindPetsWithByteArrayWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Find pet by ID - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will - /// simulate API error conditions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Updates a pet in the store with form data - /// - /// - /// ID of pet that needs to be updated - /// - /// - /// Updated name of the pet - /// - /// - /// Updated status of the pet - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task UpdatePetWithFormWithHttpMessagesAsync(string petId, string name = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Deletes a pet - /// - /// - /// Pet id to delete - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// uploads an image - /// - /// - /// ID of pet to update - /// - /// - /// Additional data to pass to server - /// - /// - /// file to upload - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task UploadFileWithHttpMessagesAsync(long petId, string additionalMetadata = default(string), Stream file = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Place an order for a pet - /// - /// - /// order placed for purchasing the pet - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> PlaceOrderWithHttpMessagesAsync(Order body = default(Order), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. - /// Other values will generated exceptions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything - /// above 1000 or nonintegers will generate API errors - /// - /// - /// ID of the order that needs to be deleted - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Create user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// Created user object - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task CreateUserWithHttpMessagesAsync(User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Creates list of users with given input array - /// - /// - /// List of user object - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Creates list of users with given input array - /// - /// - /// List of user object - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task CreateUsersWithListInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Logs user into the system - /// - /// - /// The user name for login - /// - /// - /// The password for login in clear text - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> LoginUserWithHttpMessagesAsync(string username = default(string), string password = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Logs out current logged in user session - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Get user by user name - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// name that need to be deleted - /// - /// - /// Updated user object - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task UpdateUserWithHttpMessagesAsync(string username, User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The name that needs to be deleted - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/Models/Category.cs b/Samples/1a-code-generation-minimal/Client/Models/Category.cs index 297a1b321..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/Models/Category.cs +++ b/Samples/1a-code-generation-minimal/Client/Models/Category.cs @@ -1,90 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore.Models -{ - using Newtonsoft.Json; - using System.Linq; - using System.Xml; - using System.Xml.Linq; - - public partial class Category - { - /// - /// Initializes a new instance of the Category class. - /// - public Category() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Category class. - /// - public Category(long? id = default(long?), string name = default(string)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Serializes the object to an XML node - /// - internal XElement XmlSerialize(XElement result) - { - if( null != Id ) - { - result.Add(new XElement("id", Id) ); - } - if( null != Name ) - { - result.Add(new XElement("name", Name) ); - } - return result; - } - /// - /// Deserializes an XML node to an instance of Category - /// - internal static Category XmlDeserialize(string payload) - { - // deserialize to xml and use the overload to do the work - return XmlDeserialize( XElement.Parse( payload ) ); - } - internal static Category XmlDeserialize(XElement payload) - { - var result = new Category(); - var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); - long? resultId; - if (deserializeId(payload, "id", out resultId)) - { - result.Id = resultId; - } - var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); - string resultName; - if (deserializeName(payload, "name", out resultName)) - { - result.Name = resultName; - } - return result; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/Models/Order.cs b/Samples/1a-code-generation-minimal/Client/Models/Order.cs index 063d938e2..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/Models/Order.cs +++ b/Samples/1a-code-generation-minimal/Client/Models/Order.cs @@ -1,158 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore.Models -{ - using Newtonsoft.Json; - using System.Linq; - using System.Xml; - using System.Xml.Linq; - - public partial class Order - { - /// - /// Initializes a new instance of the Order class. - /// - public Order() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Order class. - /// - /// Order Status. Possible values include: - /// 'placed', 'approved', 'delivered' - public Order(long? id = default(long?), long? petId = default(long?), int? quantity = default(int?), System.DateTime? shipDate = default(System.DateTime?), string status = default(string), bool? complete = default(bool?)) - { - Id = id; - PetId = petId; - Quantity = quantity; - ShipDate = shipDate; - Status = status; - Complete = complete; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; private set; } - - /// - /// - [JsonProperty(PropertyName = "petId")] - public long? PetId { get; set; } - - /// - /// - [JsonProperty(PropertyName = "quantity")] - public int? Quantity { get; set; } - - /// - /// - [JsonProperty(PropertyName = "shipDate")] - public System.DateTime? ShipDate { get; set; } - - /// - /// Gets or sets order Status. Possible values include: 'placed', - /// 'approved', 'delivered' - /// - [JsonProperty(PropertyName = "status")] - public string Status { get; set; } - - /// - /// - [JsonProperty(PropertyName = "complete")] - public bool? Complete { get; set; } - - /// - /// Serializes the object to an XML node - /// - internal XElement XmlSerialize(XElement result) - { - if( null != Id ) - { - result.Add(new XElement("id", Id) ); - } - if( null != PetId ) - { - result.Add(new XElement("petId", PetId) ); - } - if( null != Quantity ) - { - result.Add(new XElement("quantity", Quantity) ); - } - if( null != ShipDate ) - { - result.Add(new XElement("shipDate", ShipDate) ); - } - if( null != Status ) - { - result.Add(new XElement("status", Status) ); - } - if( null != Complete ) - { - result.Add(new XElement("complete", Complete) ); - } - return result; - } - /// - /// Deserializes an XML node to an instance of Order - /// - internal static Order XmlDeserialize(string payload) - { - // deserialize to xml and use the overload to do the work - return XmlDeserialize( XElement.Parse( payload ) ); - } - internal static Order XmlDeserialize(XElement payload) - { - var result = new Order(); - var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); - long? resultId; - if (deserializeId(payload, "id", out resultId)) - { - result.Id = resultId; - } - var deserializePetId = XmlSerialization.ToDeserializer(e => (long?)e); - long? resultPetId; - if (deserializePetId(payload, "petId", out resultPetId)) - { - result.PetId = resultPetId; - } - var deserializeQuantity = XmlSerialization.ToDeserializer(e => (int?)e); - int? resultQuantity; - if (deserializeQuantity(payload, "quantity", out resultQuantity)) - { - result.Quantity = resultQuantity; - } - var deserializeShipDate = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); - System.DateTime? resultShipDate; - if (deserializeShipDate(payload, "shipDate", out resultShipDate)) - { - result.ShipDate = resultShipDate; - } - var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); - string resultStatus; - if (deserializeStatus(payload, "status", out resultStatus)) - { - result.Status = resultStatus; - } - var deserializeComplete = XmlSerialization.ToDeserializer(e => (bool?)e); - bool? resultComplete; - if (deserializeComplete(payload, "complete", out resultComplete)) - { - result.Complete = resultComplete; - } - return result; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/Models/Pet.cs b/Samples/1a-code-generation-minimal/Client/Models/Pet.cs index 0e909c572..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/Models/Pet.cs +++ b/Samples/1a-code-generation-minimal/Client/Models/Pet.cs @@ -1,197 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - using System.Xml.Linq; - - /// - /// A pet - /// - /// - /// A group of properties representing a pet. - /// - public partial class Pet - { - /// - /// Initializes a new instance of the Pet class. - /// - public Pet() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Pet class. - /// - /// The id of the pet. - /// pet status in the store. Possible values - /// include: 'available', 'pending', 'sold' - public Pet(string name, IList photoUrls, long? id = default(long?), Category category = default(Category), IList tags = default(IList), string status = default(string)) - { - Id = id; - Category = category; - Name = name; - PhotoUrls = photoUrls; - Tags = tags; - Status = status; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the id of the pet. - /// - /// - /// A more detailed description of the id of the pet. - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "category")] - public Category Category { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "photoUrls")] - public IList PhotoUrls { get; set; } - - /// - /// - [JsonProperty(PropertyName = "tags")] - public IList Tags { get; set; } - - /// - /// Gets or sets pet status in the store. Possible values include: - /// 'available', 'pending', 'sold' - /// - [JsonProperty(PropertyName = "status")] - public string Status { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - if (PhotoUrls == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls"); - } - } - /// - /// Serializes the object to an XML node - /// - internal XElement XmlSerialize(XElement result) - { - if( null != Id ) - { - result.Add(new XElement("id", Id) ); - } - if( null != Category ) - { - result.Add(Category.XmlSerialize(new XElement( "category" ))); - } - if( null != Name ) - { - result.Add(new XElement("name", Name) ); - } - if( null != PhotoUrls ) - { - var seq = new XElement("photoUrl"); - foreach( var value in PhotoUrls ){ - seq.Add(new XElement( "photoUrl", value ) ); - } - result.Add(seq); - } - if( null != Tags ) - { - var seq = new XElement("tag"); - foreach( var value in Tags ){ - seq.Add(value.XmlSerialize( new XElement( "tag") ) ); - } - result.Add(seq); - } - if( null != Status ) - { - result.Add(new XElement("status", Status) ); - } - return result; - } - /// - /// Deserializes an XML node to an instance of Pet - /// - internal static Pet XmlDeserialize(string payload) - { - // deserialize to xml and use the overload to do the work - return XmlDeserialize( XElement.Parse( payload ) ); - } - internal static Pet XmlDeserialize(XElement payload) - { - var result = new Pet(); - var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); - long? resultId; - if (deserializeId(payload, "id", out resultId)) - { - result.Id = resultId; - } - var deserializeCategory = XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e)); - Category resultCategory; - if (deserializeCategory(payload, "category", out resultCategory)) - { - result.Category = resultCategory; - } - var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); - string resultName; - if (deserializeName(payload, "name", out resultName)) - { - result.Name = resultName; - } - var deserializePhotoUrls = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => (string)e), "photoUrl"); - IList resultPhotoUrls; - if (deserializePhotoUrls(payload, "photoUrl", out resultPhotoUrls)) - { - result.PhotoUrls = resultPhotoUrls; - } - var deserializeTags = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Tag.XmlDeserialize(e)), "tag"); - IList resultTags; - if (deserializeTags(payload, "tag", out resultTags)) - { - result.Tags = resultTags; - } - var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); - string resultStatus; - if (deserializeStatus(payload, "status", out resultStatus)) - { - result.Status = resultStatus; - } - return result; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/Models/Tag.cs b/Samples/1a-code-generation-minimal/Client/Models/Tag.cs index 9573b2f59..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/Models/Tag.cs +++ b/Samples/1a-code-generation-minimal/Client/Models/Tag.cs @@ -1,90 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore.Models -{ - using Newtonsoft.Json; - using System.Linq; - using System.Xml; - using System.Xml.Linq; - - public partial class Tag - { - /// - /// Initializes a new instance of the Tag class. - /// - public Tag() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Tag class. - /// - public Tag(long? id = default(long?), string name = default(string)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Serializes the object to an XML node - /// - internal XElement XmlSerialize(XElement result) - { - if( null != Id ) - { - result.Add(new XElement("id", Id) ); - } - if( null != Name ) - { - result.Add(new XElement("name", Name) ); - } - return result; - } - /// - /// Deserializes an XML node to an instance of Tag - /// - internal static Tag XmlDeserialize(string payload) - { - // deserialize to xml and use the overload to do the work - return XmlDeserialize( XElement.Parse( payload ) ); - } - internal static Tag XmlDeserialize(XElement payload) - { - var result = new Tag(); - var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); - long? resultId; - if (deserializeId(payload, "id", out resultId)) - { - result.Id = resultId; - } - var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); - string resultName; - if (deserializeName(payload, "name", out resultName)) - { - result.Name = resultName; - } - return result; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/Models/User.cs b/Samples/1a-code-generation-minimal/Client/Models/User.cs index 29310acd3..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/Models/User.cs +++ b/Samples/1a-code-generation-minimal/Client/Models/User.cs @@ -1,188 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore.Models -{ - using Newtonsoft.Json; - using System.Linq; - using System.Xml; - using System.Xml.Linq; - - public partial class User - { - /// - /// Initializes a new instance of the User class. - /// - public User() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the User class. - /// - /// User Status - public User(long? id = default(long?), string username = default(string), string firstName = default(string), string lastName = default(string), string email = default(string), string password = default(string), string phone = default(string), int? userStatus = default(int?)) - { - Id = id; - Username = username; - FirstName = firstName; - LastName = lastName; - Email = email; - Password = password; - Phone = phone; - UserStatus = userStatus; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "username")] - public string Username { get; set; } - - /// - /// - [JsonProperty(PropertyName = "firstName")] - public string FirstName { get; set; } - - /// - /// - [JsonProperty(PropertyName = "lastName")] - public string LastName { get; set; } - - /// - /// - [JsonProperty(PropertyName = "email")] - public string Email { get; set; } - - /// - /// - [JsonProperty(PropertyName = "password")] - public string Password { get; set; } - - /// - /// - [JsonProperty(PropertyName = "phone")] - public string Phone { get; set; } - - /// - /// Gets or sets user Status - /// - [JsonProperty(PropertyName = "userStatus")] - public int? UserStatus { get; set; } - - /// - /// Serializes the object to an XML node - /// - internal XElement XmlSerialize(XElement result) - { - if( null != Id ) - { - result.Add(new XElement("id", Id) ); - } - if( null != Username ) - { - result.Add(new XElement("username", Username) ); - } - if( null != FirstName ) - { - result.Add(new XElement("firstName", FirstName) ); - } - if( null != LastName ) - { - result.Add(new XElement("lastName", LastName) ); - } - if( null != Email ) - { - result.Add(new XElement("email", Email) ); - } - if( null != Password ) - { - result.Add(new XElement("password", Password) ); - } - if( null != Phone ) - { - result.Add(new XElement("phone", Phone) ); - } - if( null != UserStatus ) - { - result.Add(new XElement("userStatus", UserStatus) ); - } - return result; - } - /// - /// Deserializes an XML node to an instance of User - /// - internal static User XmlDeserialize(string payload) - { - // deserialize to xml and use the overload to do the work - return XmlDeserialize( XElement.Parse( payload ) ); - } - internal static User XmlDeserialize(XElement payload) - { - var result = new User(); - var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); - long? resultId; - if (deserializeId(payload, "id", out resultId)) - { - result.Id = resultId; - } - var deserializeUsername = XmlSerialization.ToDeserializer(e => (string)e); - string resultUsername; - if (deserializeUsername(payload, "username", out resultUsername)) - { - result.Username = resultUsername; - } - var deserializeFirstName = XmlSerialization.ToDeserializer(e => (string)e); - string resultFirstName; - if (deserializeFirstName(payload, "firstName", out resultFirstName)) - { - result.FirstName = resultFirstName; - } - var deserializeLastName = XmlSerialization.ToDeserializer(e => (string)e); - string resultLastName; - if (deserializeLastName(payload, "lastName", out resultLastName)) - { - result.LastName = resultLastName; - } - var deserializeEmail = XmlSerialization.ToDeserializer(e => (string)e); - string resultEmail; - if (deserializeEmail(payload, "email", out resultEmail)) - { - result.Email = resultEmail; - } - var deserializePassword = XmlSerialization.ToDeserializer(e => (string)e); - string resultPassword; - if (deserializePassword(payload, "password", out resultPassword)) - { - result.Password = resultPassword; - } - var deserializePhone = XmlSerialization.ToDeserializer(e => (string)e); - string resultPhone; - if (deserializePhone(payload, "phone", out resultPhone)) - { - result.Phone = resultPhone; - } - var deserializeUserStatus = XmlSerialization.ToDeserializer(e => (int?)e); - int? resultUserStatus; - if (deserializeUserStatus(payload, "userStatus", out resultUserStatus)) - { - result.UserStatus = resultUserStatus; - } - return result; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs b/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs index 45cec452f..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs +++ b/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs @@ -1,89 +1 @@ -namespace Petstore -{ - using System.Collections; - using System.Collections.Generic; - using System.Xml; - using System.Xml.Linq; - internal static class XmlSerialization - { - internal delegate bool XmlRootDeserializer( XElement root, out T result ); - internal delegate bool XmlDeserializer( XElement parent, string propertyName, out T result ); - internal static XmlRootDeserializer Root( XmlDeserializer deserializer ) => - (XElement root, out T result) => deserializer(new XElement("artificialRoot", root), root.Name.LocalName, out result); - private static XmlDeserializer Unroot( XmlRootDeserializer deserializer ) - { - return (XElement parent, string propertyName, out T result) => { - result = default(T); - var element = parent.Element(propertyName); - if (element == null) - { - return false; - } - return deserializer(element, out result); - }; - } - private static XmlRootDeserializer ToRootDeserializer( System.Func unsafeDeserializer ) - => (XElement root, out T result) => { - try - { - result = unsafeDeserializer(root); - return true; - } - catch - { - result = default(T); - return false; - }}; - internal static XmlDeserializer ToDeserializer( System.Func unsafeDeserializer ) - => Unroot(ToRootDeserializer(unsafeDeserializer)); - internal static XmlDeserializer> CreateListXmlDeserializer( XmlDeserializer elementDeserializer, string elementTagName = null /*if isWrapped = false*/ ) - { - if (elementTagName != null) - { - // create non-wrapped deserializer and forward - var slave = CreateListXmlDeserializer( elementDeserializer ); - return (XElement parent, string propertyName, out IList result) => { - result = null; - var wrapper = parent.Element(propertyName); - return wrapper != null && slave(wrapper, elementTagName, out result); - }; - } - var rootElementDeserializer = Root(elementDeserializer); - return (XElement parent, string propertyName, out IList result) => { - result = new List(); - foreach (var element in parent.Elements(propertyName)) - { - T elementResult; - if (!rootElementDeserializer(element, out elementResult)) - { - return false; - } - result.Add(elementResult); - } - return true; - }; - } - internal static XmlDeserializer> CreateDictionaryXmlDeserializer( XmlDeserializer elementDeserializer ) - { - return (XElement parent, string propertyName, out IDictionary result) => { - result = null; - var childElement = parent.Element(propertyName); - if (childElement == null) - { - return false; - } - result = new Dictionary(); - foreach (var element in childElement.Elements()) - { - T elementResult; - if (!elementDeserializer(childElement, element.Name.LocalName, out elementResult)) - { - return false; - } - result.Add(element.Name.LocalName, elementResult); - } - return true; - }; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs b/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs index 6d8f5c437..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs +++ b/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs @@ -1,2946 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Threading; - using System.Threading.Tasks; - - /// - /// This is a sample server Petstore server. You can find out more about - /// Swagger at <a - /// href="http://swagger.io">http://swagger.io</a> or on - /// irc.freenode.net, #swagger. For this sample, you can use the api key - /// "special-key" to test the authorization filters - /// - public partial class SwaggerPetstore : ServiceClient, ISwaggerPetstore - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BaseUri = new System.Uri("http://petstore.swagger.io/v2"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - /// - /// Fake endpoint to test byte array in body parameter for adding a new pet to - /// the store - /// - /// - /// Pet object in the form of byte array - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddPetUsingByteArrayWithHttpMessagesAsync(string body = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "AddPetUsingByteArray", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Add a new pet to the store - /// - /// - /// Adds a new pet to the store. You may receive an HTTP invalid input if your - /// pet is invalid. - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddPetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "AddPet", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Update an existing pet - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UpdatePetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UpdatePet", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405 && (int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma seperated strings - /// - /// - /// Status values that need to be considered for filter - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> FindPetsByStatusWithHttpMessagesAsync(IList status = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("status", status); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "FindPetsByStatus", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByStatus").ToString(); - List _queryParameters = new List(); - if (status != null) - { - _queryParameters.Add(string.Format("status={0}", System.Uri.EscapeDataString(string.Join(",", status)))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - IList _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), null))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Finds Pets by tags - /// - /// - /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, - /// tag3 for testing. - /// - /// - /// Tags to filter by - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("tags", tags); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "FindPetsByTags", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByTags").ToString(); - List _queryParameters = new List(); - if (tags != null) - { - _queryParameters.Add(string.Format("tags={0}", System.Uri.EscapeDataString(string.Join(",", tags)))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - IList _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), null))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> FindPetsWithByteArrayWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "FindPetsWithByteArray", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - string _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Find pet by ID - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetPetById", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - Pet _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates a pet in the store with form data - /// - /// - /// ID of pet that needs to be updated - /// - /// - /// Updated name of the pet - /// - /// - /// Updated status of the pet - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UpdatePetWithFormWithHttpMessagesAsync(string petId, string name = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (petId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "petId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("name", name); - tracingParameters.Add("status", status); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UpdatePetWithForm", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(petId)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - List> values = new List>(); - if(name != null) - { - values.Add("name", name); - } - if(status != null) - { - values.Add("status", status); - } - FormUrlEncodedContent _formContent = new FormUrlEncodedContent(values); - _httpRequest.Content = _formContent; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes a pet - /// - /// - /// Pet id to delete - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiKey", apiKey); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "DeletePet", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (apiKey != null) - { - if (_httpRequest.Headers.Contains("api_key")) - { - _httpRequest.Headers.Remove("api_key"); - } - _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// uploads an image - /// - /// - /// ID of pet to update - /// - /// - /// Additional data to pass to server - /// - /// - /// file to upload - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UploadFileWithHttpMessagesAsync(long petId, string additionalMetadata = default(string), Stream file = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("additionalMetadata", additionalMetadata); - tracingParameters.Add("file", file); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UploadFile", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}/uploadImage").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - MultipartFormDataContent _multiPartContent = new MultipartFormDataContent(); - if (additionalMetadata != null) - { - StringContent _additionalMetadata = new StringContent(additionalMetadata, System.Text.Encoding.UTF8); - _multiPartContent.Add(_additionalMetadata, "additionalMetadata"); - } - if (file != null) - { - StreamContent _file = new StreamContent(file); - _file.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); - FileStream _fileAsFileStream = file as FileStream; - if (_fileAsFileStream != null) - { - ContentDispositionHeaderValue _contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-data"); - _contentDispositionHeaderValue.Name = "file"; - _contentDispositionHeaderValue.FileName = _fileAsFileStream.Name; - _file.Headers.ContentDisposition = _contentDispositionHeaderValue; - } - _multiPartContent.Add(_file, "file"); - } - _httpRequest.Content = _multiPartContent; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetInventory", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/inventory").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - IDictionary _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => (int?)e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Place an order for a pet - /// - /// - /// order placed for purchasing the pet - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> PlaceOrderWithHttpMessagesAsync(Order body = default(Order), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "PlaceOrder", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - Order _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other - /// values will generated exceptions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (orderId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("orderId", orderId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetOrderById", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); - _url = _url.Replace("{orderId}", System.Uri.EscapeDataString(orderId)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - Order _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above - /// 1000 or nonintegers will generate API errors - /// - /// - /// ID of the order that needs to be deleted - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (orderId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("orderId", orderId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "DeleteOrder", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); - _url = _url.Replace("{orderId}", System.Uri.EscapeDataString(orderId)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// Created user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreateUserWithHttpMessagesAsync(User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates list of users with given input array - /// - /// - /// List of user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithArrayInput", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithArray").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates list of users with given input array - /// - /// - /// List of user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreateUsersWithListInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithListInput", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithList").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Logs user into the system - /// - /// - /// The user name for login - /// - /// - /// The password for login in clear text - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> LoginUserWithHttpMessagesAsync(string username = default(string), string password = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("password", password); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "LoginUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/login").ToString(); - List _queryParameters = new List(); - if (username != null) - { - _queryParameters.Add(string.Format("username={0}", System.Uri.EscapeDataString(username))); - } - if (password != null) - { - _queryParameters.Add(string.Format("password={0}", System.Uri.EscapeDataString(password))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - string _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Logs out current logged in user session - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "LogoutUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/logout").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Get user by user name - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (username == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "username"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetUserByName", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); - _url = _url.Replace("{username}", System.Uri.EscapeDataString(username)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - User _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => User.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// name that need to be deleted - /// - /// - /// Updated user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UpdateUserWithHttpMessagesAsync(string username, User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (username == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "username"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UpdateUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); - _url = _url.Replace("{username}", System.Uri.EscapeDataString(username)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The name that needs to be deleted - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (username == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "username"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "DeleteUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); - _url = _url.Replace("{username}", System.Uri.EscapeDataString(username)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs b/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs index 6167ed58b..9d6cafc2c 100644 --- a/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs +++ b/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs @@ -1,839 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore -{ - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SwaggerPetstore. - /// - public static partial class SwaggerPetstoreExtensions - { - /// - /// Fake endpoint to test byte array in body parameter for adding a new pet to - /// the store - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet object in the form of byte array - /// - public static void AddPetUsingByteArray(this ISwaggerPetstore operations, string body = default(string)) - { - operations.AddPetUsingByteArrayAsync(body).GetAwaiter().GetResult(); - } - - /// - /// Fake endpoint to test byte array in body parameter for adding a new pet to - /// the store - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet object in the form of byte array - /// - /// - /// The cancellation token. - /// - public static async Task AddPetUsingByteArrayAsync(this ISwaggerPetstore operations, string body = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddPetUsingByteArrayWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Add a new pet to the store - /// - /// - /// Adds a new pet to the store. You may receive an HTTP invalid input if your - /// pet is invalid. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet object that needs to be added to the store - /// - public static void AddPet(this ISwaggerPetstore operations, Pet body = default(Pet)) - { - operations.AddPetAsync(body).GetAwaiter().GetResult(); - } - - /// - /// Add a new pet to the store - /// - /// - /// Adds a new pet to the store. You may receive an HTTP invalid input if your - /// pet is invalid. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// The cancellation token. - /// - public static async Task AddPetAsync(this ISwaggerPetstore operations, Pet body = default(Pet), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddPetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Update an existing pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet object that needs to be added to the store - /// - public static void UpdatePet(this ISwaggerPetstore operations, Pet body = default(Pet)) - { - operations.UpdatePetAsync(body).GetAwaiter().GetResult(); - } - - /// - /// Update an existing pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// The cancellation token. - /// - public static async Task UpdatePetAsync(this ISwaggerPetstore operations, Pet body = default(Pet), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.UpdatePetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma seperated strings - /// - /// - /// The operations group for this extension method. - /// - /// - /// Status values that need to be considered for filter - /// - public static IList FindPetsByStatus(this ISwaggerPetstore operations, IList status = default(IList)) - { - return operations.FindPetsByStatusAsync(status).GetAwaiter().GetResult(); - } - - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma seperated strings - /// - /// - /// The operations group for this extension method. - /// - /// - /// Status values that need to be considered for filter - /// - /// - /// The cancellation token. - /// - public static async Task> FindPetsByStatusAsync(this ISwaggerPetstore operations, IList status = default(IList), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.FindPetsByStatusWithHttpMessagesAsync(status, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Finds Pets by tags - /// - /// - /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, - /// tag3 for testing. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Tags to filter by - /// - public static IList FindPetsByTags(this ISwaggerPetstore operations, IList tags = default(IList)) - { - return operations.FindPetsByTagsAsync(tags).GetAwaiter().GetResult(); - } - - /// - /// Finds Pets by tags - /// - /// - /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, - /// tag3 for testing. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Tags to filter by - /// - /// - /// The cancellation token. - /// - public static async Task> FindPetsByTagsAsync(this ISwaggerPetstore operations, IList tags = default(IList), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.FindPetsByTagsWithHttpMessagesAsync(tags, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be fetched - /// - public static string FindPetsWithByteArray(this ISwaggerPetstore operations, long petId) - { - return operations.FindPetsWithByteArrayAsync(petId).GetAwaiter().GetResult(); - } - - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// The cancellation token. - /// - public static async Task FindPetsWithByteArrayAsync(this ISwaggerPetstore operations, long petId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.FindPetsWithByteArrayWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Find pet by ID - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be fetched - /// - public static Pet GetPetById(this ISwaggerPetstore operations, long petId) - { - return operations.GetPetByIdAsync(petId).GetAwaiter().GetResult(); - } - - /// - /// Find pet by ID - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// The cancellation token. - /// - public static async Task GetPetByIdAsync(this ISwaggerPetstore operations, long petId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates a pet in the store with form data - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be updated - /// - /// - /// Updated name of the pet - /// - /// - /// Updated status of the pet - /// - public static void UpdatePetWithForm(this ISwaggerPetstore operations, string petId, string name = default(string), string status = default(string)) - { - operations.UpdatePetWithFormAsync(petId, name, status).GetAwaiter().GetResult(); - } - - /// - /// Updates a pet in the store with form data - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be updated - /// - /// - /// Updated name of the pet - /// - /// - /// Updated status of the pet - /// - /// - /// The cancellation token. - /// - public static async Task UpdatePetWithFormAsync(this ISwaggerPetstore operations, string petId, string name = default(string), string status = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.UpdatePetWithFormWithHttpMessagesAsync(petId, name, status, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Deletes a pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet id to delete - /// - /// - /// - public static void DeletePet(this ISwaggerPetstore operations, long petId, string apiKey = default(string)) - { - operations.DeletePetAsync(petId, apiKey).GetAwaiter().GetResult(); - } - - /// - /// Deletes a pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// Pet id to delete - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task DeletePetAsync(this ISwaggerPetstore operations, long petId, string apiKey = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeletePetWithHttpMessagesAsync(petId, apiKey, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// uploads an image - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet to update - /// - /// - /// Additional data to pass to server - /// - /// - /// file to upload - /// - public static void UploadFile(this ISwaggerPetstore operations, long petId, string additionalMetadata = default(string), Stream file = default(Stream)) - { - operations.UploadFileAsync(petId, additionalMetadata, file).GetAwaiter().GetResult(); - } - - /// - /// uploads an image - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet to update - /// - /// - /// Additional data to pass to server - /// - /// - /// file to upload - /// - /// - /// The cancellation token. - /// - public static async Task UploadFileAsync(this ISwaggerPetstore operations, long petId, string additionalMetadata = default(string), Stream file = default(Stream), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.UploadFileWithHttpMessagesAsync(petId, additionalMetadata, file, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// - /// The operations group for this extension method. - /// - public static IDictionary GetInventory(this ISwaggerPetstore operations) - { - return operations.GetInventoryAsync().GetAwaiter().GetResult(); - } - - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> GetInventoryAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetInventoryWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Place an order for a pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// order placed for purchasing the pet - /// - public static Order PlaceOrder(this ISwaggerPetstore operations, Order body = default(Order)) - { - return operations.PlaceOrderAsync(body).GetAwaiter().GetResult(); - } - - /// - /// Place an order for a pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// order placed for purchasing the pet - /// - /// - /// The cancellation token. - /// - public static async Task PlaceOrderAsync(this ISwaggerPetstore operations, Order body = default(Order), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.PlaceOrderWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other - /// values will generated exceptions - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be fetched - /// - public static Order GetOrderById(this ISwaggerPetstore operations, string orderId) - { - return operations.GetOrderByIdAsync(orderId).GetAwaiter().GetResult(); - } - - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other - /// values will generated exceptions - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// The cancellation token. - /// - public static async Task GetOrderByIdAsync(this ISwaggerPetstore operations, string orderId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetOrderByIdWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above - /// 1000 or nonintegers will generate API errors - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of the order that needs to be deleted - /// - public static void DeleteOrder(this ISwaggerPetstore operations, string orderId) - { - operations.DeleteOrderAsync(orderId).GetAwaiter().GetResult(); - } - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above - /// 1000 or nonintegers will generate API errors - /// - /// - /// The operations group for this extension method. - /// - /// - /// ID of the order that needs to be deleted - /// - /// - /// The cancellation token. - /// - public static async Task DeleteOrderAsync(this ISwaggerPetstore operations, string orderId, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteOrderWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Create user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Created user object - /// - public static void CreateUser(this ISwaggerPetstore operations, User body = default(User)) - { - operations.CreateUserAsync(body).GetAwaiter().GetResult(); - } - - /// - /// Create user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Created user object - /// - /// - /// The cancellation token. - /// - public static async Task CreateUserAsync(this ISwaggerPetstore operations, User body = default(User), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CreateUserWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates list of users with given input array - /// - /// - /// The operations group for this extension method. - /// - /// - /// List of user object - /// - public static void CreateUsersWithArrayInput(this ISwaggerPetstore operations, IList body = default(IList)) - { - operations.CreateUsersWithArrayInputAsync(body).GetAwaiter().GetResult(); - } - - /// - /// Creates list of users with given input array - /// - /// - /// The operations group for this extension method. - /// - /// - /// List of user object - /// - /// - /// The cancellation token. - /// - public static async Task CreateUsersWithArrayInputAsync(this ISwaggerPetstore operations, IList body = default(IList), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CreateUsersWithArrayInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates list of users with given input array - /// - /// - /// The operations group for this extension method. - /// - /// - /// List of user object - /// - public static void CreateUsersWithListInput(this ISwaggerPetstore operations, IList body = default(IList)) - { - operations.CreateUsersWithListInputAsync(body).GetAwaiter().GetResult(); - } - - /// - /// Creates list of users with given input array - /// - /// - /// The operations group for this extension method. - /// - /// - /// List of user object - /// - /// - /// The cancellation token. - /// - public static async Task CreateUsersWithListInputAsync(this ISwaggerPetstore operations, IList body = default(IList), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CreateUsersWithListInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Logs user into the system - /// - /// - /// The operations group for this extension method. - /// - /// - /// The user name for login - /// - /// - /// The password for login in clear text - /// - public static string LoginUser(this ISwaggerPetstore operations, string username = default(string), string password = default(string)) - { - return operations.LoginUserAsync(username, password).GetAwaiter().GetResult(); - } - - /// - /// Logs user into the system - /// - /// - /// The operations group for this extension method. - /// - /// - /// The user name for login - /// - /// - /// The password for login in clear text - /// - /// - /// The cancellation token. - /// - public static async Task LoginUserAsync(this ISwaggerPetstore operations, string username = default(string), string password = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.LoginUserWithHttpMessagesAsync(username, password, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Logs out current logged in user session - /// - /// - /// The operations group for this extension method. - /// - public static void LogoutUser(this ISwaggerPetstore operations) - { - operations.LogoutUserAsync().GetAwaiter().GetResult(); - } - - /// - /// Logs out current logged in user session - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task LogoutUserAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.LogoutUserWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Get user by user name - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// - public static User GetUserByName(this ISwaggerPetstore operations, string username) - { - return operations.GetUserByNameAsync(username).GetAwaiter().GetResult(); - } - - /// - /// Get user by user name - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// - /// - /// The cancellation token. - /// - public static async Task GetUserByNameAsync(this ISwaggerPetstore operations, string username, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetUserByNameWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The operations group for this extension method. - /// - /// - /// name that need to be deleted - /// - /// - /// Updated user object - /// - public static void UpdateUser(this ISwaggerPetstore operations, string username, User body = default(User)) - { - operations.UpdateUserAsync(username, body).GetAwaiter().GetResult(); - } - - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The operations group for this extension method. - /// - /// - /// name that need to be deleted - /// - /// - /// Updated user object - /// - /// - /// The cancellation token. - /// - public static async Task UpdateUserAsync(this ISwaggerPetstore operations, string username, User body = default(User), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.UpdateUserWithHttpMessagesAsync(username, body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name that needs to be deleted - /// - public static void DeleteUser(this ISwaggerPetstore operations, string username) - { - operations.DeleteUserAsync(username).GetAwaiter().GetResult(); - } - - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name that needs to be deleted - /// - /// - /// The cancellation token. - /// - public static async Task DeleteUserAsync(this ISwaggerPetstore operations, string username, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteUserWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs index 0b8342e64..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs @@ -1,100 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// - public partial interface ISwaggerPetstore : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// List all pets - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task,ListPetsHeadersInner>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Create a pet - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task CreatePetsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Info for a specific pet - /// - /// - /// The id of the pet to retrieve - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs index b9ab4bcbc..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class Error - { - /// - /// Initializes a new instance of the Error class. - /// - public Error() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Error class. - /// - public Error(int code, string message) - { - Code = code; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "code")] - public int Code { get; set; } - - /// - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Message == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Message"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs index 732613f31..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Microsoft.Rest; - - /// - /// Exception thrown for an invalid response with Error information. - /// - public class ErrorException : RestException - { - /// - /// Gets information about the associated HTTP request. - /// - public HttpRequestMessageWrapper Request { get; set; } - - /// - /// Gets information about the associated HTTP response. - /// - public HttpResponseMessageWrapper Response { get; set; } - - /// - /// Gets or sets the body object. - /// - public Error Body { get; set; } - - /// - /// Initializes a new instance of the ErrorException class. - /// - public ErrorException() - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - public ErrorException(string message) - : this(message, null) - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - /// Inner exception. - public ErrorException(string message, System.Exception innerException) - : base(message, innerException) - { - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs index 54fb59ddc..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs @@ -1,47 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines headers for listPets operation. - /// - public partial class ListPetsHeadersInner - { - /// - /// Initializes a new instance of the ListPetsHeadersInner class. - /// - public ListPetsHeadersInner() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ListPetsHeadersInner class. - /// - /// A link to the next page of responses - public ListPetsHeadersInner(string xNext = default(string)) - { - XNext = xNext; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a link to the next page of responses - /// - [JsonProperty(PropertyName = "x-next")] - public string XNext { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs index d32527e2c..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs @@ -1,68 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class PetInner - { - /// - /// Initializes a new instance of the PetInner class. - /// - public PetInner() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PetInner class. - /// - public PetInner(long id, string name, string tag = default(string)) - { - Id = id; - Name = name; - Tag = tag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "tag")] - public string Tag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs index 60211ca12..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs @@ -1,772 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - public partial class SwaggerPetstore : ServiceClient, ISwaggerPetstore, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BaseUri = new System.Uri("http://petstore.swagger.io/v1"); - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - /// - /// List all pets - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task,ListPetsHeadersInner>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("limit", limit); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListPets", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets").ToString(); - List _queryParameters = new List(); - if (limit != null) - { - _queryParameters.Add(string.Format("limit={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(limit, SerializationSettings).Trim('"')))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse,ListPetsHeadersInner>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create a pet - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreatePetsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreatePets", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets").ToString(); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Info for a specific pet - /// - /// - /// The id of the pet to retrieve - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (petId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "petId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ShowPetById", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(petId)); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstoreExtensions.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstoreExtensions.cs index 72de5f9ef..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstoreExtensions.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstoreExtensions.cs @@ -1,116 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SwaggerPetstore. - /// - public static partial class SwaggerPetstoreExtensions - { - /// - /// List all pets - /// - /// - /// The operations group for this extension method. - /// - /// - /// How many items to return at one time (max 100) - /// - public static IList ListPets(this ISwaggerPetstore operations, int? limit = default(int?)) - { - return operations.ListPetsAsync(limit).GetAwaiter().GetResult(); - } - - /// - /// List all pets - /// - /// - /// The operations group for this extension method. - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// The cancellation token. - /// - public static async Task> ListPetsAsync(this ISwaggerPetstore operations, int? limit = default(int?), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListPetsWithHttpMessagesAsync(limit, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Create a pet - /// - /// - /// The operations group for this extension method. - /// - public static void CreatePets(this ISwaggerPetstore operations) - { - operations.CreatePetsAsync().GetAwaiter().GetResult(); - } - - /// - /// Create a pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task CreatePetsAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CreatePetsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Info for a specific pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The id of the pet to retrieve - /// - public static IList ShowPetById(this ISwaggerPetstore operations, string petId) - { - return operations.ShowPetByIdAsync(petId).GetAwaiter().GetResult(); - } - - /// - /// Info for a specific pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The id of the pet to retrieve - /// - /// - /// The cancellation token. - /// - public static async Task> ShowPetByIdAsync(this ISwaggerPetstore operations, string petId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ShowPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp/ISwaggerPetstoreClient.cs b/Samples/1b-code-generation-multilang/Azure.CSharp/ISwaggerPetstoreClient.cs index b4db077a8..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp/ISwaggerPetstoreClient.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp/ISwaggerPetstoreClient.cs @@ -1,100 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// - public partial interface ISwaggerPetstoreClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// List all pets - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Create a pet - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task CreatePetsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Info for a specific pet - /// - /// - /// The id of the pet to retrieve - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Error.cs b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Error.cs index b9ab4bcbc..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Error.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Error.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class Error - { - /// - /// Initializes a new instance of the Error class. - /// - public Error() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Error class. - /// - public Error(int code, string message) - { - Code = code; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "code")] - public int Code { get; set; } - - /// - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Message == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Message"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ErrorException.cs b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ErrorException.cs index 732613f31..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ErrorException.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ErrorException.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Microsoft.Rest; - - /// - /// Exception thrown for an invalid response with Error information. - /// - public class ErrorException : RestException - { - /// - /// Gets information about the associated HTTP request. - /// - public HttpRequestMessageWrapper Request { get; set; } - - /// - /// Gets information about the associated HTTP response. - /// - public HttpResponseMessageWrapper Response { get; set; } - - /// - /// Gets or sets the body object. - /// - public Error Body { get; set; } - - /// - /// Initializes a new instance of the ErrorException class. - /// - public ErrorException() - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - public ErrorException(string message) - : this(message, null) - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - /// Inner exception. - public ErrorException(string message, System.Exception innerException) - : base(message, innerException) - { - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ListPetsHeaders.cs b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ListPetsHeaders.cs index cfaf2232c..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ListPetsHeaders.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/ListPetsHeaders.cs @@ -1,47 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines headers for listPets operation. - /// - public partial class ListPetsHeaders - { - /// - /// Initializes a new instance of the ListPetsHeaders class. - /// - public ListPetsHeaders() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ListPetsHeaders class. - /// - /// A link to the next page of responses - public ListPetsHeaders(string xNext = default(string)) - { - XNext = xNext; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a link to the next page of responses - /// - [JsonProperty(PropertyName = "x-next")] - public string XNext { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Pet.cs b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Pet.cs index d89354865..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Pet.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp/Models/Pet.cs @@ -1,68 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class Pet - { - /// - /// Initializes a new instance of the Pet class. - /// - public Pet() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Pet class. - /// - public Pet(long id, string name, string tag = default(string)) - { - Id = id; - Name = name; - Tag = tag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "tag")] - public string Tag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClient.cs b/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClient.cs index 269b5e00c..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClient.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClient.cs @@ -1,772 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - public partial class SwaggerPetstoreClient : ServiceClient, ISwaggerPetstoreClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected SwaggerPetstoreClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected SwaggerPetstoreClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected SwaggerPetstoreClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected SwaggerPetstoreClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstoreClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstoreClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstoreClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SwaggerPetstoreClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstoreClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BaseUri = new System.Uri("http://petstore.swagger.io/v1"); - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - /// - /// List all pets - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("limit", limit); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListPets", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets").ToString(); - List _queryParameters = new List(); - if (limit != null) - { - _queryParameters.Add(string.Format("limit={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(limit, SerializationSettings).Trim('"')))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse,ListPetsHeaders>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create a pet - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreatePetsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreatePets", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets").ToString(); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Info for a specific pet - /// - /// - /// The id of the pet to retrieve - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (petId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "petId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ShowPetById", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(petId)); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClientExtensions.cs b/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClientExtensions.cs index a1f50d213..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClientExtensions.cs +++ b/Samples/1b-code-generation-multilang/Azure.CSharp/SwaggerPetstoreClientExtensions.cs @@ -1,116 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace cowstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SwaggerPetstoreClient. - /// - public static partial class SwaggerPetstoreClientExtensions - { - /// - /// List all pets - /// - /// - /// The operations group for this extension method. - /// - /// - /// How many items to return at one time (max 100) - /// - public static IList ListPets(this ISwaggerPetstoreClient operations, int? limit = default(int?)) - { - return operations.ListPetsAsync(limit).GetAwaiter().GetResult(); - } - - /// - /// List all pets - /// - /// - /// The operations group for this extension method. - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// The cancellation token. - /// - public static async Task> ListPetsAsync(this ISwaggerPetstoreClient operations, int? limit = default(int?), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListPetsWithHttpMessagesAsync(limit, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Create a pet - /// - /// - /// The operations group for this extension method. - /// - public static void CreatePets(this ISwaggerPetstoreClient operations) - { - operations.CreatePetsAsync().GetAwaiter().GetResult(); - } - - /// - /// Create a pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task CreatePetsAsync(this ISwaggerPetstoreClient operations, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CreatePetsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Info for a specific pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The id of the pet to retrieve - /// - public static IList ShowPetById(this ISwaggerPetstoreClient operations, string petId) - { - return operations.ShowPetByIdAsync(petId).GetAwaiter().GetResult(); - } - - /// - /// Info for a specific pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The id of the pet to retrieve - /// - /// - /// The cancellation token. - /// - public static async Task> ShowPetByIdAsync(this ISwaggerPetstoreClient operations, string petId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ShowPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/Error.java b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/Error.java index 4d1f62bc0..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/Error.java +++ b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/Error.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Error model. - */ -public class Error { - /** - * The code property. - */ - @JsonProperty(value = "code", required = true) - private int code; - - /** - * The message property. - */ - @JsonProperty(value = "message", required = true) - private String message; - - /** - * Get the code value. - * - * @return the code value - */ - public int code() { - return this.code; - } - - /** - * Set the code value. - * - * @param code the code value to set - * @return the Error object itself. - */ - public Error withCode(int code) { - this.code = code; - return this; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } - - /** - * Set the message value. - * - * @param message the message value to set - * @return the Error object itself. - */ - public Error withMessage(String message) { - this.message = message; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/ErrorException.java b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/ErrorException.java index a6f986f34..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/ErrorException.java +++ b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/ErrorException.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore; - -import com.microsoft.rest.RestException; -import okhttp3.ResponseBody; -import retrofit2.Response; - -/** - * Exception thrown for an invalid response with Error information. - */ -public class ErrorException extends RestException { - /** - * Initializes a new instance of the ErrorException class. - * - * @param message the exception message or the response content if a message is not available - * @param response the HTTP response - */ - public ErrorException(final String message, final Response response) { - super(message, response); - } - - /** - * Initializes a new instance of the ErrorException class. - * - * @param message the exception message or the response content if a message is not available - * @param response the HTTP response - * @param body the deserialized response body - */ - public ErrorException(final String message, final Response response, final Error body) { - super(message, response, body); - } - - @Override - public Error body() { - return (Error) super.body(); - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/ListPetsHeadersInner.java b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/ListPetsHeadersInner.java index 9a354d468..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/ListPetsHeadersInner.java +++ b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/ListPetsHeadersInner.java @@ -1,41 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.implementation; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Defines headers for listPets operation. - */ -public class ListPetsHeadersInner { - /** - * A link to the next page of responses. - */ - @JsonProperty(value = "x-next") - private String xNext; - - /** - * Get the xNext value. - * - * @return the xNext value - */ - public String xNext() { - return this.xNext; - } - - /** - * Set the xNext value. - * - * @param xNext the xNext value to set - * @return the ListPetsHeadersInner object itself. - */ - public ListPetsHeadersInner withXNext(String xNext) { - this.xNext = xNext; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/PetInner.java b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/PetInner.java index e6e9d2a8a..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/PetInner.java +++ b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/PetInner.java @@ -1,93 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.implementation; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The PetInner model. - */ -public class PetInner { - /** - * The id property. - */ - @JsonProperty(value = "id", required = true) - private long id; - - /** - * The name property. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * The tag property. - */ - @JsonProperty(value = "tag") - private String tag; - - /** - * Get the id value. - * - * @return the id value - */ - public long id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the PetInner object itself. - */ - public PetInner withId(long id) { - this.id = id; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the PetInner object itself. - */ - public PetInner withName(String name) { - this.name = name; - return this; - } - - /** - * Get the tag value. - * - * @return the tag value - */ - public String tag() { - return this.tag; - } - - /** - * Set the tag value. - * - * @param tag the tag value to set - * @return the PetInner object itself. - */ - public PetInner withTag(String tag) { - this.tag = tag; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/SwaggerPetstoreImpl.java b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/SwaggerPetstoreImpl.java index aaee0c2ee..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/SwaggerPetstoreImpl.java +++ b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/SwaggerPetstoreImpl.java @@ -1,457 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.implementation; - -import com.google.common.reflect.TypeToken; -import com.microsoft.azure.AzureClient; -import com.microsoft.azure.AzureServiceClient; -import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.RestClient; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseWithHeaders; -import cowstore.ErrorException; -import java.io.IOException; -import java.util.List; -import okhttp3.ResponseBody; -import retrofit2.http.GET; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * Initializes a new instance of the SwaggerPetstoreImpl class. - */ -public class SwaggerPetstoreImpl extends AzureServiceClient { - /** The Retrofit service to perform REST calls. */ - private SwaggerPetstoreService service; - /** the {@link AzureClient} used for long running operations. */ - private AzureClient azureClient; - - /** - * Gets the {@link AzureClient} used for long running operations. - * @return the azure client; - */ - public AzureClient getAzureClient() { - return this.azureClient; - } - - /** Gets or sets the preferred language for the response. */ - private String acceptLanguage; - - /** - * Gets Gets or sets the preferred language for the response. - * - * @return the acceptLanguage value. - */ - public String acceptLanguage() { - return this.acceptLanguage; - } - - /** - * Sets Gets or sets the preferred language for the response. - * - * @param acceptLanguage the acceptLanguage value. - * @return the service client itself - */ - public SwaggerPetstoreImpl withAcceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - - /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ - private int longRunningOperationRetryTimeout; - - /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @return the longRunningOperationRetryTimeout value. - */ - public int longRunningOperationRetryTimeout() { - return this.longRunningOperationRetryTimeout; - } - - /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. - * @return the service client itself - */ - public SwaggerPetstoreImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { - this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; - return this; - } - - /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ - private boolean generateClientRequestId; - - /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @return the generateClientRequestId value. - */ - public boolean generateClientRequestId() { - return this.generateClientRequestId; - } - - /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @param generateClientRequestId the generateClientRequestId value. - * @return the service client itself - */ - public SwaggerPetstoreImpl withGenerateClientRequestId(boolean generateClientRequestId) { - this.generateClientRequestId = generateClientRequestId; - return this; - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param credentials the management credentials for Azure - */ - public SwaggerPetstoreImpl(ServiceClientCredentials credentials) { - this("http://petstore.swagger.io/v1", credentials); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param baseUrl the base URL of the host - * @param credentials the management credentials for Azure - */ - public SwaggerPetstoreImpl(String baseUrl, ServiceClientCredentials credentials) { - super(baseUrl, credentials); - initialize(); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param restClient the REST client to connect to Azure. - */ - public SwaggerPetstoreImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - protected void initialize() { - this.acceptLanguage = "en-US"; - this.longRunningOperationRetryTimeout = 30; - this.generateClientRequestId = true; - this.azureClient = new AzureClient(this); - initializeService(); - } - - /** - * Gets the User-Agent header for the client. - * - * @return the user agent string. - */ - @Override - public String userAgent() { - return String.format("%s (%s, %s)", super.userAgent(), "SwaggerPetstore", "1.0.0"); - } - - private void initializeService() { - service = restClient().retrofit().create(SwaggerPetstoreService.class); - } - - /** - * The interface defining all the services for SwaggerPetstore to be - * used by Retrofit to perform actually REST calls. - */ - interface SwaggerPetstoreService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: cowstore.SwaggerPetstore listPets" }) - @GET("pets") - Observable> listPets(@Query("limit") Integer limit, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: cowstore.SwaggerPetstore createPets" }) - @POST("pets") - Observable> createPets(@Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: cowstore.SwaggerPetstore showPetById" }) - @GET("pets/{petId}") - Observable> showPetById(@Path("petId") String petId, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<PetInner> object if successful. - */ - public List listPets() { - return listPetsWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * List all pets. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listPetsAsync(final ServiceCallback> serviceCallback) { - return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(), serviceCallback); - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<PetInner> object - */ - public Observable> listPetsAsync() { - return listPetsWithServiceResponseAsync().map(new Func1, ListPetsHeadersInner>, List>() { - @Override - public List call(ServiceResponseWithHeaders, ListPetsHeadersInner> response) { - return response.body(); - } - }); - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<PetInner> object - */ - public Observable, ListPetsHeadersInner>> listPetsWithServiceResponseAsync() { - final Integer limit = null; - return service.listPets(limit, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable, ListPetsHeadersInner>>>() { - @Override - public Observable, ListPetsHeadersInner>> call(Response response) { - try { - ServiceResponseWithHeaders, ListPetsHeadersInner> clientResponse = listPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<PetInner> object if successful. - */ - public List listPets(Integer limit) { - return listPetsWithServiceResponseAsync(limit).toBlocking().single().body(); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listPetsAsync(Integer limit, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(limit), serviceCallback); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<PetInner> object - */ - public Observable> listPetsAsync(Integer limit) { - return listPetsWithServiceResponseAsync(limit).map(new Func1, ListPetsHeadersInner>, List>() { - @Override - public List call(ServiceResponseWithHeaders, ListPetsHeadersInner> response) { - return response.body(); - } - }); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<PetInner> object - */ - public Observable, ListPetsHeadersInner>> listPetsWithServiceResponseAsync(Integer limit) { - return service.listPets(limit, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable, ListPetsHeadersInner>>>() { - @Override - public Observable, ListPetsHeadersInner>> call(Response response) { - try { - ServiceResponseWithHeaders, ListPetsHeadersInner> clientResponse = listPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponseWithHeaders, ListPetsHeadersInner> listPetsDelegate(Response response) throws ErrorException, IOException { - return this.restClient().responseBuilderFactory()., ErrorException>newInstance(this.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(ErrorException.class) - .buildWithHeaders(response, ListPetsHeadersInner.class); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void createPets() { - createPetsWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Create a pet. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture createPetsAsync(final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createPetsWithServiceResponseAsync(), serviceCallback); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable createPetsAsync() { - return createPetsWithServiceResponseAsync().map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> createPetsWithServiceResponseAsync() { - return service.createPets(this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse createPetsDelegate(Response response) throws ErrorException, IOException { - return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) - .register(201, new TypeToken() { }.getType()) - .registerError(ErrorException.class) - .build(response); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<PetInner> object if successful. - */ - public List showPetById(String petId) { - return showPetByIdWithServiceResponseAsync(petId).toBlocking().single().body(); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> showPetByIdAsync(String petId, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(showPetByIdWithServiceResponseAsync(petId), serviceCallback); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<PetInner> object - */ - public Observable> showPetByIdAsync(String petId) { - return showPetByIdWithServiceResponseAsync(petId).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<PetInner> object - */ - public Observable>> showPetByIdWithServiceResponseAsync(String petId) { - if (petId == null) { - throw new IllegalArgumentException("Parameter petId is required and cannot be null."); - } - return service.showPetById(petId, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> clientResponse = showPetByIdDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse> showPetByIdDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { - return this.restClient().responseBuilderFactory()., ErrorException>newInstance(this.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(ErrorException.class) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/package-info.java b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/package-info.java index e048af23e..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/package-info.java +++ b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/implementation/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for SwaggerPetstore. - */ -package cowstore.implementation; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/package-info.java b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/package-info.java index f898f0d92..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/package-info.java +++ b/Samples/1b-code-generation-multilang/Azure.Java.Fluent/src/main/java/cowstore/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the classes for SwaggerPetstore. - */ -package cowstore; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/SwaggerPetstore.java b/Samples/1b-code-generation-multilang/Azure.Java/SwaggerPetstore.java index 9133a3eb1..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/SwaggerPetstore.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/SwaggerPetstore.java @@ -1,237 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore; - -import com.microsoft.azure.AzureClient; -import com.microsoft.rest.RestClient; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseWithHeaders; -import cowstore.models.ErrorException; -import cowstore.models.ListPetsHeaders; -import cowstore.models.Pet; -import java.io.IOException; -import java.util.List; -import rx.Observable; - -/** - * The interface for SwaggerPetstore class. - */ -public interface SwaggerPetstore { - /** - * Gets the REST client. - * - * @return the {@link RestClient} object. - */ - RestClient restClient(); - - /** - * Gets the {@link AzureClient} used for long running operations. - * @return the azure client; - */ - AzureClient getAzureClient(); - - /** - * Gets the User-Agent header for the client. - * - * @return the user agent string. - */ - String userAgent(); - - /** - * Gets Gets or sets the preferred language for the response.. - * - * @return the acceptLanguage value. - */ - String acceptLanguage(); - - /** - * Sets Gets or sets the preferred language for the response.. - * - * @param acceptLanguage the acceptLanguage value. - * @return the service client itself - */ - SwaggerPetstore withAcceptLanguage(String acceptLanguage); - - /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. - * - * @return the longRunningOperationRetryTimeout value. - */ - int longRunningOperationRetryTimeout(); - - /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. - * - * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. - * @return the service client itself - */ - SwaggerPetstore withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); - - /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. - * - * @return the generateClientRequestId value. - */ - boolean generateClientRequestId(); - - /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. - * - * @param generateClientRequestId the generateClientRequestId value. - * @return the service client itself - */ - SwaggerPetstore withGenerateClientRequestId(boolean generateClientRequestId); - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - List listPets(); - - /** - * List all pets. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> listPetsAsync(final ServiceCallback> serviceCallback); - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable> listPetsAsync(); - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync(); - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - List listPets(Integer limit); - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> listPetsAsync(Integer limit, final ServiceCallback> serviceCallback); - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable> listPetsAsync(Integer limit); - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync(Integer limit); - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void createPets(); - - /** - * Create a pet. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture createPetsAsync(final ServiceCallback serviceCallback); - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable createPetsAsync(); - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> createPetsWithServiceResponseAsync(); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - List showPetById(String petId); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> showPetByIdAsync(String petId, final ServiceCallback> serviceCallback); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable> showPetByIdAsync(String petId); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable>> showPetByIdWithServiceResponseAsync(String petId); - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/implementation/SwaggerPetstoreImpl.java b/Samples/1b-code-generation-multilang/Azure.Java/implementation/SwaggerPetstoreImpl.java index b3dd79fe3..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/implementation/SwaggerPetstoreImpl.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/implementation/SwaggerPetstoreImpl.java @@ -1,460 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.implementation; - -import com.google.common.reflect.TypeToken; -import com.microsoft.azure.AzureClient; -import com.microsoft.azure.AzureServiceClient; -import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.RestClient; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseWithHeaders; -import cowstore.models.ErrorException; -import cowstore.models.ListPetsHeaders; -import cowstore.models.Pet; -import cowstore.SwaggerPetstore; -import java.io.IOException; -import java.util.List; -import okhttp3.ResponseBody; -import retrofit2.http.GET; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * Initializes a new instance of the SwaggerPetstoreImpl class. - */ -public class SwaggerPetstoreImpl extends AzureServiceClient implements SwaggerPetstore { - /** The Retrofit service to perform REST calls. */ - private SwaggerPetstoreService service; - /** the {@link AzureClient} used for long running operations. */ - private AzureClient azureClient; - - /** - * Gets the {@link AzureClient} used for long running operations. - * @return the azure client; - */ - public AzureClient getAzureClient() { - return this.azureClient; - } - - /** Gets or sets the preferred language for the response. */ - private String acceptLanguage; - - /** - * Gets Gets or sets the preferred language for the response. - * - * @return the acceptLanguage value. - */ - public String acceptLanguage() { - return this.acceptLanguage; - } - - /** - * Sets Gets or sets the preferred language for the response. - * - * @param acceptLanguage the acceptLanguage value. - * @return the service client itself - */ - public SwaggerPetstoreImpl withAcceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - - /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ - private int longRunningOperationRetryTimeout; - - /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @return the longRunningOperationRetryTimeout value. - */ - public int longRunningOperationRetryTimeout() { - return this.longRunningOperationRetryTimeout; - } - - /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. - * @return the service client itself - */ - public SwaggerPetstoreImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { - this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; - return this; - } - - /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ - private boolean generateClientRequestId; - - /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @return the generateClientRequestId value. - */ - public boolean generateClientRequestId() { - return this.generateClientRequestId; - } - - /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @param generateClientRequestId the generateClientRequestId value. - * @return the service client itself - */ - public SwaggerPetstoreImpl withGenerateClientRequestId(boolean generateClientRequestId) { - this.generateClientRequestId = generateClientRequestId; - return this; - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param credentials the management credentials for Azure - */ - public SwaggerPetstoreImpl(ServiceClientCredentials credentials) { - this("http://petstore.swagger.io/v1", credentials); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param baseUrl the base URL of the host - * @param credentials the management credentials for Azure - */ - public SwaggerPetstoreImpl(String baseUrl, ServiceClientCredentials credentials) { - super(baseUrl, credentials); - initialize(); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param restClient the REST client to connect to Azure. - */ - public SwaggerPetstoreImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - protected void initialize() { - this.acceptLanguage = "en-US"; - this.longRunningOperationRetryTimeout = 30; - this.generateClientRequestId = true; - this.azureClient = new AzureClient(this); - initializeService(); - } - - /** - * Gets the User-Agent header for the client. - * - * @return the user agent string. - */ - @Override - public String userAgent() { - return String.format("%s (%s, %s)", super.userAgent(), "SwaggerPetstore", "1.0.0"); - } - - private void initializeService() { - service = restClient().retrofit().create(SwaggerPetstoreService.class); - } - - /** - * The interface defining all the services for SwaggerPetstore to be - * used by Retrofit to perform actually REST calls. - */ - interface SwaggerPetstoreService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: cowstore.SwaggerPetstore listPets" }) - @GET("pets") - Observable> listPets(@Query("limit") Integer limit, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: cowstore.SwaggerPetstore createPets" }) - @POST("pets") - Observable> createPets(@Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: cowstore.SwaggerPetstore showPetById" }) - @GET("pets/{petId}") - Observable> showPetById(@Path("petId") String petId, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - public List listPets() { - return listPetsWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * List all pets. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listPetsAsync(final ServiceCallback> serviceCallback) { - return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(), serviceCallback); - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable> listPetsAsync() { - return listPetsWithServiceResponseAsync().map(new Func1, ListPetsHeaders>, List>() { - @Override - public List call(ServiceResponseWithHeaders, ListPetsHeaders> response) { - return response.body(); - } - }); - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync() { - final Integer limit = null; - return service.listPets(limit, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable, ListPetsHeaders>>>() { - @Override - public Observable, ListPetsHeaders>> call(Response response) { - try { - ServiceResponseWithHeaders, ListPetsHeaders> clientResponse = listPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - public List listPets(Integer limit) { - return listPetsWithServiceResponseAsync(limit).toBlocking().single().body(); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listPetsAsync(Integer limit, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(limit), serviceCallback); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable> listPetsAsync(Integer limit) { - return listPetsWithServiceResponseAsync(limit).map(new Func1, ListPetsHeaders>, List>() { - @Override - public List call(ServiceResponseWithHeaders, ListPetsHeaders> response) { - return response.body(); - } - }); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync(Integer limit) { - return service.listPets(limit, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable, ListPetsHeaders>>>() { - @Override - public Observable, ListPetsHeaders>> call(Response response) { - try { - ServiceResponseWithHeaders, ListPetsHeaders> clientResponse = listPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponseWithHeaders, ListPetsHeaders> listPetsDelegate(Response response) throws ErrorException, IOException { - return this.restClient().responseBuilderFactory()., ErrorException>newInstance(this.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(ErrorException.class) - .buildWithHeaders(response, ListPetsHeaders.class); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void createPets() { - createPetsWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Create a pet. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture createPetsAsync(final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createPetsWithServiceResponseAsync(), serviceCallback); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable createPetsAsync() { - return createPetsWithServiceResponseAsync().map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> createPetsWithServiceResponseAsync() { - return service.createPets(this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse createPetsDelegate(Response response) throws ErrorException, IOException { - return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) - .register(201, new TypeToken() { }.getType()) - .registerError(ErrorException.class) - .build(response); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - public List showPetById(String petId) { - return showPetByIdWithServiceResponseAsync(petId).toBlocking().single().body(); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> showPetByIdAsync(String petId, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(showPetByIdWithServiceResponseAsync(petId), serviceCallback); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable> showPetByIdAsync(String petId) { - return showPetByIdWithServiceResponseAsync(petId).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable>> showPetByIdWithServiceResponseAsync(String petId) { - if (petId == null) { - throw new IllegalArgumentException("Parameter petId is required and cannot be null."); - } - return service.showPetById(petId, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> clientResponse = showPetByIdDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse> showPetByIdDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { - return this.restClient().responseBuilderFactory()., ErrorException>newInstance(this.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(ErrorException.class) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/implementation/package-info.java b/Samples/1b-code-generation-multilang/Azure.Java/implementation/package-info.java index e048af23e..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/implementation/package-info.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/implementation/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for SwaggerPetstore. - */ -package cowstore.implementation; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/models/Error.java b/Samples/1b-code-generation-multilang/Azure.Java/models/Error.java index 446773949..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/models/Error.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/models/Error.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Error model. - */ -public class Error { - /** - * The code property. - */ - @JsonProperty(value = "code", required = true) - private int code; - - /** - * The message property. - */ - @JsonProperty(value = "message", required = true) - private String message; - - /** - * Get the code value. - * - * @return the code value - */ - public int code() { - return this.code; - } - - /** - * Set the code value. - * - * @param code the code value to set - * @return the Error object itself. - */ - public Error withCode(int code) { - this.code = code; - return this; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } - - /** - * Set the message value. - * - * @param message the message value to set - * @return the Error object itself. - */ - public Error withMessage(String message) { - this.message = message; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/models/ErrorException.java b/Samples/1b-code-generation-multilang/Azure.Java/models/ErrorException.java index 5c2f4de4a..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/models/ErrorException.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/models/ErrorException.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.models; - -import com.microsoft.rest.RestException; -import okhttp3.ResponseBody; -import retrofit2.Response; - -/** - * Exception thrown for an invalid response with Error information. - */ -public class ErrorException extends RestException { - /** - * Initializes a new instance of the ErrorException class. - * - * @param message the exception message or the response content if a message is not available - * @param response the HTTP response - */ - public ErrorException(final String message, final Response response) { - super(message, response); - } - - /** - * Initializes a new instance of the ErrorException class. - * - * @param message the exception message or the response content if a message is not available - * @param response the HTTP response - * @param body the deserialized response body - */ - public ErrorException(final String message, final Response response, final Error body) { - super(message, response, body); - } - - @Override - public Error body() { - return (Error) super.body(); - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/models/ListPetsHeaders.java b/Samples/1b-code-generation-multilang/Azure.Java/models/ListPetsHeaders.java index c870e1bef..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/models/ListPetsHeaders.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/models/ListPetsHeaders.java @@ -1,41 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Defines headers for listPets operation. - */ -public class ListPetsHeaders { - /** - * A link to the next page of responses. - */ - @JsonProperty(value = "x-next") - private String xNext; - - /** - * Get the xNext value. - * - * @return the xNext value - */ - public String xNext() { - return this.xNext; - } - - /** - * Set the xNext value. - * - * @param xNext the xNext value to set - * @return the ListPetsHeaders object itself. - */ - public ListPetsHeaders withXNext(String xNext) { - this.xNext = xNext; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/models/Pet.java b/Samples/1b-code-generation-multilang/Azure.Java/models/Pet.java index 96e1dbd99..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/models/Pet.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/models/Pet.java @@ -1,93 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package cowstore.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Pet model. - */ -public class Pet { - /** - * The id property. - */ - @JsonProperty(value = "id", required = true) - private long id; - - /** - * The name property. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * The tag property. - */ - @JsonProperty(value = "tag") - private String tag; - - /** - * Get the id value. - * - * @return the id value - */ - public long id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the Pet object itself. - */ - public Pet withId(long id) { - this.id = id; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Pet object itself. - */ - public Pet withName(String name) { - this.name = name; - return this; - } - - /** - * Get the tag value. - * - * @return the tag value - */ - public String tag() { - return this.tag; - } - - /** - * Set the tag value. - * - * @param tag the tag value to set - * @return the Pet object itself. - */ - public Pet withTag(String tag) { - this.tag = tag; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/models/package-info.java b/Samples/1b-code-generation-multilang/Azure.Java/models/package-info.java index a8a833de0..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/models/package-info.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/models/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the models classes for SwaggerPetstore. - */ -package cowstore.models; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Java/package-info.java b/Samples/1b-code-generation-multilang/Azure.Java/package-info.java index f898f0d92..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Java/package-info.java +++ b/Samples/1b-code-generation-multilang/Azure.Java/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the classes for SwaggerPetstore. - */ -package cowstore; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.NodeJS/models/errorModel.js b/Samples/1b-code-generation-multilang/Azure.NodeJS/models/errorModel.js index e091c9143..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.NodeJS/models/errorModel.js +++ b/Samples/1b-code-generation-multilang/Azure.NodeJS/models/errorModel.js @@ -1,55 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * Class representing a ErrorModel. - */ -class ErrorModel { - /** - * Create a ErrorModel. - * @member {number} code - * @member {string} message - */ - constructor() { - } - - /** - * Defines the metadata of ErrorModel - * - * @returns {object} metadata of ErrorModel - * - */ - mapper() { - return { - required: false, - serializedName: 'Error', - type: { - name: 'Composite', - className: 'ErrorModel', - modelProperties: { - code: { - required: true, - serializedName: 'code', - type: { - name: 'Number' - } - }, - message: { - required: true, - serializedName: 'message', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = ErrorModel; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.NodeJS/models/index.js b/Samples/1b-code-generation-multilang/Azure.NodeJS/models/index.js index 17e67ae32..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.NodeJS/models/index.js +++ b/Samples/1b-code-generation-multilang/Azure.NodeJS/models/index.js @@ -1,18 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -var msRestAzure = require('ms-rest-azure'); - -exports.BaseResource = msRestAzure.BaseResource; -exports.CloudError = msRestAzure.CloudError; -exports.Pet = require('./pet'); -exports.ErrorModel = require('./errorModel'); +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.NodeJS/models/pet.js b/Samples/1b-code-generation-multilang/Azure.NodeJS/models/pet.js index 07e34cbe6..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.NodeJS/models/pet.js +++ b/Samples/1b-code-generation-multilang/Azure.NodeJS/models/pet.js @@ -1,63 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * Class representing a Pet. - */ -class Pet { - /** - * Create a Pet. - * @member {number} id - * @member {string} name - * @member {string} [tag] - */ - constructor() { - } - - /** - * Defines the metadata of Pet - * - * @returns {object} metadata of Pet - * - */ - mapper() { - return { - required: false, - serializedName: 'Pet', - type: { - name: 'Composite', - className: 'Pet', - modelProperties: { - id: { - required: true, - serializedName: 'id', - type: { - name: 'Number' - } - }, - name: { - required: true, - serializedName: 'name', - type: { - name: 'String' - } - }, - tag: { - required: false, - serializedName: 'tag', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = Pet; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.NodeJS/swaggerPetstore.js b/Samples/1b-code-generation-multilang/Azure.NodeJS/swaggerPetstore.js index 3ddcd1c01..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.NodeJS/swaggerPetstore.js +++ b/Samples/1b-code-generation-multilang/Azure.NodeJS/swaggerPetstore.js @@ -1,717 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -const msRest = require('ms-rest'); -const msRestAzure = require('ms-rest-azure'); -const ServiceClient = msRestAzure.AzureServiceClient; -const WebResource = msRest.WebResource; - -const models = require('./models'); - - -/** - * @summary List all pets - * - * @param {object} [options] Optional Parameters. - * - * @param {number} [options.limit] How many items to return at one time (max - * 100) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _listPets(options, callback) { - /* jshint validthis: true */ - let client = this; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - let limit = (options && options.limit !== undefined) ? options.limit : undefined; - // Validate - try { - if (limit !== null && limit !== undefined && typeof limit !== 'number') { - throw new Error('limit must be of type number.'); - } - if (this.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'pets'; - let queryParameters = []; - if (limit !== null && limit !== undefined) { - queryParameters.push('limit=' + encodeURIComponent(limit.toString())); - } - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorModel']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = { - required: false, - serializedName: 'parsedResponse', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'PetElementType', - type: { - name: 'Composite', - className: 'Pet' - } - } - } - }; - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @summary Create a pet - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _createPets(options, callback) { - /* jshint validthis: true */ - let client = this; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - // Validate - try { - if (this.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'pets'; - let queryParameters = []; - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 201) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorModel']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @summary Info for a specific pet - * - * @param {string} petId The id of the pet to retrieve - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _showPetById(petId, options, callback) { - /* jshint validthis: true */ - let client = this; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - // Validate - try { - if (petId === null || petId === undefined || typeof petId.valueOf() !== 'string') { - throw new Error('petId cannot be null or undefined and it must be of type string.'); - } - if (this.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'pets/{petId}'; - requestUrl = requestUrl.replace('{petId}', encodeURIComponent(petId)); - let queryParameters = []; - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorModel']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = { - required: false, - serializedName: 'parsedResponse', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'PetElementType', - type: { - name: 'Composite', - className: 'Pet' - } - } - } - }; - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a SwaggerPetstore. */ -class SwaggerPetstore extends ServiceClient { - /** - * Create a SwaggerPetstore. - * @param {credentials} credentials - Credentials needed for the client to connect to Azure. - * @param {string} [baseUri] - The base URI of the service. - * @param {object} [options] - The parameter options - * @param {Array} [options.filters] - Filters to be added to the request pipeline - * @param {object} [options.requestOptions] - Options for the underlying request object - * {@link https://github.com/request/request#requestoptions-callback Options doc} - * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy - * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. - * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - */ - constructor(credentials, baseUri, options) { - if (credentials === null || credentials === undefined) { - throw new Error('\'credentials\' cannot be null.'); - } - - if (!options) options = {}; - - super(credentials, options); - - this.acceptLanguage = 'en-US'; - this.longRunningOperationRetryTimeout = 30; - this.generateClientRequestId = true; - this.baseUri = baseUri; - if (!this.baseUri) { - this.baseUri = 'http://petstore.swagger.io/v1'; - } - this.credentials = credentials; - - let packageInfo = this.getPackageJsonInfo(__dirname); - this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); - if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { - this.acceptLanguage = options.acceptLanguage; - } - if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { - this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; - } - if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { - this.generateClientRequestId = options.generateClientRequestId; - } - this.models = models; - this._listPets = _listPets; - this._createPets = _createPets; - this._showPetById = _showPetById; - msRest.addSerializationMixin(this); - } - - /** - * @summary List all pets - * - * @param {object} [options] Optional Parameters. - * - * @param {number} [options.limit] How many items to return at one time (max - * 100) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - listPetsWithHttpOperationResponse(options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._listPets(options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary List all pets - * - * @param {object} [options] Optional Parameters. - * - * @param {number} [options.limit] How many items to return at one time (max - * 100) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {Array} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - listPets(options, optionalCallback) { - let client = this; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._listPets(options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._listPets(options, optionalCallback); - } - } - - /** - * @summary Create a pet - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - createPetsWithHttpOperationResponse(options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._createPets(options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary Create a pet - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - createPets(options, optionalCallback) { - let client = this; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._createPets(options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._createPets(options, optionalCallback); - } - } - - /** - * @summary Info for a specific pet - * - * @param {string} petId The id of the pet to retrieve - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - showPetByIdWithHttpOperationResponse(petId, options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._showPetById(petId, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary Info for a specific pet - * - * @param {string} petId The id of the pet to retrieve - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {Array} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - showPetById(petId, options, optionalCallback) { - let client = this; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._showPetById(petId, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._showPetById(petId, options, optionalCallback); - } - } - -} - -module.exports = SwaggerPetstore; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore.rb b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore.rb index b9b5a1b7f..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore.rb +++ b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore.rb @@ -1,29 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -require 'uri' -require 'cgi' -require 'date' -require 'json' -require 'base64' -require 'erb' -require 'securerandom' -require 'time' -require 'timeliness' -require 'faraday' -require 'faraday-cookie_jar' -require 'concurrent' -require 'ms_rest' -require 'generated/petstore/module_definition' -require 'ms_rest_azure' - -module cowstore - autoload :SwaggerPetstore, 'generated/petstore/swagger_petstore.rb' - - module Models - autoload :Error, 'generated/petstore/models/error.rb' - autoload :Pet, 'generated/petstore/models/pet.rb' - end -end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/error.rb b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/error.rb index fe7732401..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/error.rb +++ b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/error.rb @@ -1,55 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore - module Models - # - # Model object. - # - # - class Error - - include MsRestAzure - - # @return [Integer] - attr_accessor :code - - # @return [String] - attr_accessor :message - - - # - # Mapper for Error class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Error', - type: { - name: 'Composite', - class_name: 'Error', - model_properties: { - code: { - required: true, - serialized_name: 'code', - type: { - name: 'Number' - } - }, - message: { - required: true, - serialized_name: 'message', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/pet.rb b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/pet.rb index 05aa55675..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/pet.rb +++ b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/models/pet.rb @@ -1,65 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore - module Models - # - # Model object. - # - # - class Pet - - include MsRestAzure - - # @return [Integer] - attr_accessor :id - - # @return [String] - attr_accessor :name - - # @return [String] - attr_accessor :tag - - - # - # Mapper for Pet class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Pet', - type: { - name: 'Composite', - class_name: 'Pet', - model_properties: { - id: { - required: true, - serialized_name: 'id', - type: { - name: 'Number' - } - }, - name: { - required: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - tag: { - required: false, - serialized_name: 'tag', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/module_definition.rb b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/module_definition.rb index 3c2f8703f..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/module_definition.rb +++ b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/module_definition.rb @@ -1,6 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/swagger_petstore.rb b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/swagger_petstore.rb index 9c9ddd3a7..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/swagger_petstore.rb +++ b/Samples/1b-code-generation-multilang/Azure.Ruby/generated/petstore/swagger_petstore.rb @@ -1,381 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore - # - # A service client - single point of access to the REST API. - # - class SwaggerPetstore < MsRestAzure::AzureServiceClient - include MsRestAzure - include MsRestAzure::Serialization - - # @return [String] the base URI of the service. - attr_accessor :base_url - - # @return Credentials needed for the client to connect to Azure. - attr_reader :credentials - - # @return [String] Gets or sets the preferred language for the response. - attr_accessor :accept_language - - # @return [Integer] Gets or sets the retry timeout in seconds for Long - # Running Operations. Default value is 30. - attr_accessor :long_running_operation_retry_timeout - - # @return [Boolean] When set to true a unique x-ms-client-request-id value - # is generated and included in each request. Default is true. - attr_accessor :generate_client_request_id - - # - # Creates initializes a new instance of the SwaggerPetstore class. - # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. - # @param base_url [String] the base URI of the service. - # @param options [Array] filters to be applied to the HTTP requests. - # - def initialize(credentials = nil, base_url = nil, options = nil) - super(credentials, options) - @base_url = base_url || 'http://petstore.swagger.io/v1' - - fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? - @credentials = credentials - - @accept_language = 'en-US' - @long_running_operation_retry_timeout = 30 - @generate_client_request_id = true - add_telemetry - end - - # - # Makes a request and returns the body of the response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Hash{String=>String}] containing the body of the response. - # Example: - # - # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}" - # path = "/path" - # options = { - # body: request_content, - # query_params: {'api-version' => '2016-02-01'} - # } - # result = @client.make_request(:put, path, options) - # - def make_request(method, path, options = {}) - result = make_request_with_http_info(method, path, options) - result.body unless result.nil? - end - - # - # Makes a request and returns the operation response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status. - # - def make_request_with_http_info(method, path, options = {}) - result = make_request_async(method, path, options).value! - result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body) - result - end - - # - # Makes a request asynchronously. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def make_request_async(method, path, options = {}) - fail ArgumentError, 'method is nil' if method.nil? - fail ArgumentError, 'path is nil' if path.nil? - - request_url = options[:base_url] || @base_url - - request_headers = @request_headers - request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil? - options.merge!({headers: request_headers.merge(options[:headers] || {})}) - options.merge!({credentials: @credentials}) unless @credentials.nil? - - super(request_url, method, path, options) - end - - # - # List all pets - # - # @param limit [Integer] How many items to return at one time (max 100) - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Array] operation results. - # - def list_pets(limit = nil, custom_headers = nil) - response = list_pets_async(limit, custom_headers).value! - response.body unless response.nil? - end - - # - # List all pets - # - # @param limit [Integer] How many items to return at one time (max 100) - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def list_pets_with_http_info(limit = nil, custom_headers = nil) - list_pets_async(limit, custom_headers).value! - end - - # - # List all pets - # - # @param limit [Integer] How many items to return at one time (max 100) - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_pets_async(limit = nil, custom_headers = nil) - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = accept_language unless accept_language.nil? - path_template = 'pets' - - request_url = @base_url || self.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - query_params: {'limit' => limit}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = self.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = { - required: false, - serialized_name: 'parsed_response', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'PetElementType', - type: { - name: 'Composite', - class_name: 'Pet' - } - } - } - } - result.body = self.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Create a pet - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def create_pets(custom_headers = nil) - response = create_pets_async(custom_headers).value! - nil - end - - # - # Create a pet - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def create_pets_with_http_info(custom_headers = nil) - create_pets_async(custom_headers).value! - end - - # - # Create a pet - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def create_pets_async(custom_headers = nil) - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = accept_language unless accept_language.nil? - path_template = 'pets' - - request_url = @base_url || self.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = self.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 201 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - - result - end - - promise.execute - end - - # - # Info for a specific pet - # - # @param pet_id [String] The id of the pet to retrieve - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Array] operation results. - # - def show_pet_by_id(pet_id, custom_headers = nil) - response = show_pet_by_id_async(pet_id, custom_headers).value! - response.body unless response.nil? - end - - # - # Info for a specific pet - # - # @param pet_id [String] The id of the pet to retrieve - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def show_pet_by_id_with_http_info(pet_id, custom_headers = nil) - show_pet_by_id_async(pet_id, custom_headers).value! - end - - # - # Info for a specific pet - # - # @param pet_id [String] The id of the pet to retrieve - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def show_pet_by_id_async(pet_id, custom_headers = nil) - fail ArgumentError, 'pet_id is nil' if pet_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = accept_language unless accept_language.nil? - path_template = 'pets/{petId}' - - request_url = @base_url || self.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'petId' => pet_id}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = self.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = { - required: false, - serialized_name: 'parsed_response', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'PetElementType', - type: { - name: 'Composite', - class_name: 'Pet' - } - } - } - } - result.body = self.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - - private - # - # Adds telemetry information. - # - def add_telemetry - sdk_information = 'petstore' - if defined? cowstore::VERSION - sdk_information = "#{sdk_information}/#{cowstore::VERSION}" - end - add_user_agent_information(sdk_information) - end - end -end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/CSharp/ISwaggerPetstore.cs b/Samples/1b-code-generation-multilang/CSharp/ISwaggerPetstore.cs index 81f912ecf..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/CSharp/ISwaggerPetstore.cs +++ b/Samples/1b-code-generation-multilang/CSharp/ISwaggerPetstore.cs @@ -1,77 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CSharpNamespace -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// - public partial interface ISwaggerPetstore : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// List all pets - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Create a pet - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task CreatePetsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Info for a specific pet - /// - /// - /// The id of the pet to retrieve - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/CSharp/Models/Error.cs b/Samples/1b-code-generation-multilang/CSharp/Models/Error.cs index b69c6a1c9..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/CSharp/Models/Error.cs +++ b/Samples/1b-code-generation-multilang/CSharp/Models/Error.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CSharpNamespace.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class Error - { - /// - /// Initializes a new instance of the Error class. - /// - public Error() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Error class. - /// - public Error(int code, string message) - { - Code = code; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "code")] - public int Code { get; set; } - - /// - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Message == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Message"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/CSharp/Models/ErrorException.cs b/Samples/1b-code-generation-multilang/CSharp/Models/ErrorException.cs index 9336e6aee..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/CSharp/Models/ErrorException.cs +++ b/Samples/1b-code-generation-multilang/CSharp/Models/ErrorException.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CSharpNamespace.Models -{ - using Microsoft.Rest; - - /// - /// Exception thrown for an invalid response with Error information. - /// - public class ErrorException : RestException - { - /// - /// Gets information about the associated HTTP request. - /// - public HttpRequestMessageWrapper Request { get; set; } - - /// - /// Gets information about the associated HTTP response. - /// - public HttpResponseMessageWrapper Response { get; set; } - - /// - /// Gets or sets the body object. - /// - public Error Body { get; set; } - - /// - /// Initializes a new instance of the ErrorException class. - /// - public ErrorException() - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - public ErrorException(string message) - : this(message, null) - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - /// Inner exception. - public ErrorException(string message, System.Exception innerException) - : base(message, innerException) - { - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/CSharp/Models/ListPetsHeaders.cs b/Samples/1b-code-generation-multilang/CSharp/Models/ListPetsHeaders.cs index eb8318049..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/CSharp/Models/ListPetsHeaders.cs +++ b/Samples/1b-code-generation-multilang/CSharp/Models/ListPetsHeaders.cs @@ -1,47 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CSharpNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines headers for listPets operation. - /// - public partial class ListPetsHeaders - { - /// - /// Initializes a new instance of the ListPetsHeaders class. - /// - public ListPetsHeaders() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ListPetsHeaders class. - /// - /// A link to the next page of responses - public ListPetsHeaders(string xNext = default(string)) - { - XNext = xNext; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a link to the next page of responses - /// - [JsonProperty(PropertyName = "x-next")] - public string XNext { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/CSharp/Models/Pet.cs b/Samples/1b-code-generation-multilang/CSharp/Models/Pet.cs index ed897ec32..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/CSharp/Models/Pet.cs +++ b/Samples/1b-code-generation-multilang/CSharp/Models/Pet.cs @@ -1,68 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CSharpNamespace.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class Pet - { - /// - /// Initializes a new instance of the Pet class. - /// - public Pet() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Pet class. - /// - public Pet(long id, string name, string tag = default(string)) - { - Id = id; - Name = name; - Tag = tag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "tag")] - public string Tag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstore.cs b/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstore.cs index 5c7e77e43..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstore.cs +++ b/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstore.cs @@ -1,546 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CSharpNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - public partial class SwaggerPetstore : ServiceClient, ISwaggerPetstore - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BaseUri = new System.Uri("http://petstore.swagger.io/v1"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - /// - /// List all pets - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("limit", limit); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListPets", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets").ToString(); - List _queryParameters = new List(); - if (limit != null) - { - _queryParameters.Add(string.Format("limit={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(limit, SerializationSettings).Trim('"')))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse,ListPetsHeaders>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create a pet - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreatePetsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreatePets", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Info for a specific pet - /// - /// - /// The id of the pet to retrieve - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (petId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "petId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ShowPetById", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(petId)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstoreExtensions.cs b/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstoreExtensions.cs index cd206b5d4..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstoreExtensions.cs +++ b/Samples/1b-code-generation-multilang/CSharp/SwaggerPetstoreExtensions.cs @@ -1,114 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CSharpNamespace -{ - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SwaggerPetstore. - /// - public static partial class SwaggerPetstoreExtensions - { - /// - /// List all pets - /// - /// - /// The operations group for this extension method. - /// - /// - /// How many items to return at one time (max 100) - /// - public static IList ListPets(this ISwaggerPetstore operations, int? limit = default(int?)) - { - return operations.ListPetsAsync(limit).GetAwaiter().GetResult(); - } - - /// - /// List all pets - /// - /// - /// The operations group for this extension method. - /// - /// - /// How many items to return at one time (max 100) - /// - /// - /// The cancellation token. - /// - public static async Task> ListPetsAsync(this ISwaggerPetstore operations, int? limit = default(int?), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListPetsWithHttpMessagesAsync(limit, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Create a pet - /// - /// - /// The operations group for this extension method. - /// - public static void CreatePets(this ISwaggerPetstore operations) - { - operations.CreatePetsAsync().GetAwaiter().GetResult(); - } - - /// - /// Create a pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task CreatePetsAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CreatePetsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Info for a specific pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The id of the pet to retrieve - /// - public static IList ShowPetById(this ISwaggerPetstore operations, string petId) - { - return operations.ShowPetByIdAsync(petId).GetAwaiter().GetResult(); - } - - /// - /// Info for a specific pet - /// - /// - /// The operations group for this extension method. - /// - /// - /// The id of the pet to retrieve - /// - /// - /// The cancellation token. - /// - public static async Task> ShowPetByIdAsync(this ISwaggerPetstore operations, string petId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ShowPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Go/client.go b/Samples/1b-code-generation-multilang/Go/client.go index 0b479da32..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Go/client.go +++ b/Samples/1b-code-generation-multilang/Go/client.go @@ -1,205 +1 @@ -// Package cowstore implements the Azure ARM Cowstore service API version 1.0.0. -// -// -package cowstore - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -const ( - // DefaultBaseURI is the default URI used for the service Cowstore - DefaultBaseURI = "http://petstore.swagger.io/v1" -) - -// ManagementClient is the base client for Cowstore. -type ManagementClient struct { - autorest.Client - BaseURI string - } - -// New creates an instance of the ManagementClient client. -func New()ManagementClient { - return NewWithBaseURI(DefaultBaseURI, ) -} - - // NewWithBaseURI creates an instance of the ManagementClient client. - func NewWithBaseURI(baseURI string, ) ManagementClient { - return ManagementClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - } - } - - // CreatePets sends the create pets request. - func (client ManagementClient) CreatePets() (result autorest.Response, err error) { - req, err := client.CreatePetsPreparer() - if err != nil { - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "CreatePets", nil , "Failure preparing request") - return - } - - resp, err := client.CreatePetsSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "CreatePets", resp, "Failure sending request") - return - } - - result, err = client.CreatePetsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "CreatePets", resp, "Failure responding to request") - } - - return - } - - // CreatePetsPreparer prepares the CreatePets request. - func (client ManagementClient) CreatePetsPreparer() (*http.Request, error) { - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/pets")) - return preparer.Prepare(&http.Request{}) - } - - // CreatePetsSender sends the CreatePets request. The method will close the - // http.Response Body if it receives an error. - func (client ManagementClient) CreatePetsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) - } - - // CreatePetsResponder handles the response to the CreatePets request. The method always - // closes the http.Response Body. - func (client ManagementClient) CreatePetsResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), - autorest.ByClosing()) - result.Response = resp - return - } - - // ListPets sends the list pets request. - // - // limit is how many items to return at one time (max 100) - func (client ManagementClient) ListPets(limit *int32) (result ListPet, err error) { - req, err := client.ListPetsPreparer(limit) - if err != nil { - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "ListPets", nil , "Failure preparing request") - return - } - - resp, err := client.ListPetsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "ListPets", resp, "Failure sending request") - return - } - - result, err = client.ListPetsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "ListPets", resp, "Failure responding to request") - } - - return - } - - // ListPetsPreparer prepares the ListPets request. - func (client ManagementClient) ListPetsPreparer(limit *int32) (*http.Request, error) { - queryParameters := map[string]interface{} { - } - if limit != nil { - queryParameters["limit"] = autorest.Encode("query",*limit) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/pets"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) - } - - // ListPetsSender sends the ListPets request. The method will close the - // http.Response Body if it receives an error. - func (client ManagementClient) ListPetsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) - } - - // ListPetsResponder handles the response to the ListPets request. The method always - // closes the http.Response Body. - func (client ManagementClient) ListPetsResponder(resp *http.Response) (result ListPet, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - - // ShowPetByID sends the show pet by id request. - // - // petID is the id of the pet to retrieve - func (client ManagementClient) ShowPetByID(petID string) (result ListPet, err error) { - req, err := client.ShowPetByIDPreparer(petID) - if err != nil { - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "ShowPetByID", nil , "Failure preparing request") - return - } - - resp, err := client.ShowPetByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "ShowPetByID", resp, "Failure sending request") - return - } - - result, err = client.ShowPetByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cowstore.ManagementClient", "ShowPetByID", resp, "Failure responding to request") - } - - return - } - - // ShowPetByIDPreparer prepares the ShowPetByID request. - func (client ManagementClient) ShowPetByIDPreparer(petID string) (*http.Request, error) { - pathParameters := map[string]interface{} { - "petId": autorest.Encode("path",petID), - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/pets/{petId}",pathParameters)) - return preparer.Prepare(&http.Request{}) - } - - // ShowPetByIDSender sends the ShowPetByID request. The method will close the - // http.Response Body if it receives an error. - func (client ManagementClient) ShowPetByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) - } - - // ShowPetByIDResponder handles the response to the ShowPetByID request. The method always - // closes the http.Response Body. - func (client ManagementClient) ShowPetByIDResponder(resp *http.Response) (result ListPet, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Go/models.go b/Samples/1b-code-generation-multilang/Go/models.go index 0fc0622e8..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Go/models.go +++ b/Samples/1b-code-generation-multilang/Go/models.go @@ -1,28 +1 @@ -package cowstore - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -// Error is -type Error struct { -Code *int32 `json:"code,omitempty"` -Message *string `json:"message,omitempty"` -} - -// ListPet is -type ListPet struct { -autorest.Response `json:"-"` -Value *[]Pet `json:"value,omitempty"` -} - -// Pet is -type Pet struct { -ID *int64 `json:"id,omitempty"` -Name *string `json:"name,omitempty"` -Tag *string `json:"tag,omitempty"` -} - +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Go/version.go b/Samples/1b-code-generation-multilang/Go/version.go index ccbcc956f..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Go/version.go +++ b/Samples/1b-code-generation-multilang/Go/version.go @@ -1,15 +1 @@ -package cowstore - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/0.0.0 arm-cowstore/1.0.0" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return "0.0.0" -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/SwaggerPetstore.java b/Samples/1b-code-generation-multilang/Java/SwaggerPetstore.java index 3ebac1fa6..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/SwaggerPetstore.java +++ b/Samples/1b-code-generation-multilang/Java/SwaggerPetstore.java @@ -1,183 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package javanamespace; - -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseWithHeaders; -import java.io.IOException; -import java.util.List; -import javanamespace.models.ErrorException; -import javanamespace.models.ListPetsHeaders; -import javanamespace.models.Pet; -import rx.Observable; -import com.microsoft.rest.RestClient; - -/** - * The interface for SwaggerPetstore class. - */ -public interface SwaggerPetstore { - /** - * Gets the REST client. - * - * @return the {@link RestClient} object. - */ - RestClient restClient(); - - /** - * The default base URL. - */ - String DEFAULT_BASE_URL = "http://petstore.swagger.io/v1"; - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - List listPets(); - - /** - * List all pets. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> listPetsAsync(final ServiceCallback> serviceCallback); - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable> listPetsAsync(); - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync(); - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - List listPets(Integer limit); - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> listPetsAsync(Integer limit, final ServiceCallback> serviceCallback); - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable> listPetsAsync(Integer limit); - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync(Integer limit); - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void createPets(); - - /** - * Create a pet. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture createPetsAsync(final ServiceCallback serviceCallback); - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable createPetsAsync(); - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> createPetsWithServiceResponseAsync(); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - List showPetById(String petId); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> showPetByIdAsync(String petId, final ServiceCallback> serviceCallback); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable> showPetByIdAsync(String petId); - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - Observable>> showPetByIdWithServiceResponseAsync(String petId); - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/implementation/SwaggerPetstoreImpl.java b/Samples/1b-code-generation-multilang/Java/implementation/SwaggerPetstoreImpl.java index 2442c513d..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/implementation/SwaggerPetstoreImpl.java +++ b/Samples/1b-code-generation-multilang/Java/implementation/SwaggerPetstoreImpl.java @@ -1,388 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package javanamespace.implementation; - -import javanamespace.SwaggerPetstore; -import com.microsoft.rest.ServiceClient; -import com.microsoft.rest.RestClient; -import okhttp3.OkHttpClient; -import retrofit2.Retrofit; -import com.google.common.reflect.TypeToken; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseWithHeaders; -import java.io.IOException; -import java.util.List; -import javanamespace.models.ErrorException; -import javanamespace.models.ListPetsHeaders; -import javanamespace.models.Pet; -import okhttp3.ResponseBody; -import retrofit2.http.GET; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * Initializes a new instance of the SwaggerPetstore class. - */ -public class SwaggerPetstoreImpl extends ServiceClient implements SwaggerPetstore { - /** - * The Retrofit service to perform REST calls. - */ - private SwaggerPetstoreService service; - - /** - * Initializes an instance of SwaggerPetstore client. - */ - public SwaggerPetstoreImpl() { - this("http://petstore.swagger.io/v1"); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param baseUrl the base URL of the host - */ - public SwaggerPetstoreImpl(String baseUrl) { - super(baseUrl); - initialize(); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public SwaggerPetstoreImpl(OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - this("http://petstore.swagger.io/v1", clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param baseUrl the base URL of the host - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public SwaggerPetstoreImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - super(baseUrl, clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of SwaggerPetstore client. - * - * @param restClient the REST client containing pre-configured settings - */ - public SwaggerPetstoreImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - private void initialize() { - initializeService(); - } - - private void initializeService() { - service = retrofit().create(SwaggerPetstoreService.class); - } - - /** - * The interface defining all the services for SwaggerPetstore to be - * used by Retrofit to perform actually REST calls. - */ - interface SwaggerPetstoreService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: javanamespace.SwaggerPetstore listPets" }) - @GET("pets") - Observable> listPets(@Query("limit") Integer limit); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: javanamespace.SwaggerPetstore createPets" }) - @POST("pets") - Observable> createPets(); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: javanamespace.SwaggerPetstore showPetById" }) - @GET("pets/{petId}") - Observable> showPetById(@Path("petId") String petId); - - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - public List listPets() { - return listPetsWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * List all pets. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listPetsAsync(final ServiceCallback> serviceCallback) { - return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(), serviceCallback); - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable> listPetsAsync() { - return listPetsWithServiceResponseAsync().map(new Func1, ListPetsHeaders>, List>() { - @Override - public List call(ServiceResponseWithHeaders, ListPetsHeaders> response) { - return response.body(); - } - }); - } - - /** - * List all pets. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync() { - final Integer limit = null; - return service.listPets(limit) - .flatMap(new Func1, Observable, ListPetsHeaders>>>() { - @Override - public Observable, ListPetsHeaders>> call(Response response) { - try { - ServiceResponseWithHeaders, ListPetsHeaders> clientResponse = listPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - public List listPets(Integer limit) { - return listPetsWithServiceResponseAsync(limit).toBlocking().single().body(); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listPetsAsync(Integer limit, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(limit), serviceCallback); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable> listPetsAsync(Integer limit) { - return listPetsWithServiceResponseAsync(limit).map(new Func1, ListPetsHeaders>, List>() { - @Override - public List call(ServiceResponseWithHeaders, ListPetsHeaders> response) { - return response.body(); - } - }); - } - - /** - * List all pets. - * - * @param limit How many items to return at one time (max 100) - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable, ListPetsHeaders>> listPetsWithServiceResponseAsync(Integer limit) { - return service.listPets(limit) - .flatMap(new Func1, Observable, ListPetsHeaders>>>() { - @Override - public Observable, ListPetsHeaders>> call(Response response) { - try { - ServiceResponseWithHeaders, ListPetsHeaders> clientResponse = listPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponseWithHeaders, ListPetsHeaders> listPetsDelegate(Response response) throws ErrorException, IOException { - return this.restClient().responseBuilderFactory()., ErrorException>newInstance(this.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(ErrorException.class) - .buildWithHeaders(response, ListPetsHeaders.class); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void createPets() { - createPetsWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Create a pet. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture createPetsAsync(final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createPetsWithServiceResponseAsync(), serviceCallback); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable createPetsAsync() { - return createPetsWithServiceResponseAsync().map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Create a pet. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> createPetsWithServiceResponseAsync() { - return service.createPets() - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createPetsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse createPetsDelegate(Response response) throws ErrorException, IOException { - return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) - .register(201, new TypeToken() { }.getType()) - .registerError(ErrorException.class) - .build(response); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Pet> object if successful. - */ - public List showPetById(String petId) { - return showPetByIdWithServiceResponseAsync(petId).toBlocking().single().body(); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> showPetByIdAsync(String petId, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(showPetByIdWithServiceResponseAsync(petId), serviceCallback); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable> showPetByIdAsync(String petId) { - return showPetByIdWithServiceResponseAsync(petId).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - - /** - * Info for a specific pet. - * - * @param petId The id of the pet to retrieve - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Pet> object - */ - public Observable>> showPetByIdWithServiceResponseAsync(String petId) { - if (petId == null) { - throw new IllegalArgumentException("Parameter petId is required and cannot be null."); - } - return service.showPetById(petId) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> clientResponse = showPetByIdDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse> showPetByIdDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { - return this.restClient().responseBuilderFactory()., ErrorException>newInstance(this.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(ErrorException.class) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/implementation/package-info.java b/Samples/1b-code-generation-multilang/Java/implementation/package-info.java index 1deb6d6c0..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/implementation/package-info.java +++ b/Samples/1b-code-generation-multilang/Java/implementation/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for SwaggerPetstore. - */ -package javanamespace.implementation; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/models/Error.java b/Samples/1b-code-generation-multilang/Java/models/Error.java index a424ac869..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/models/Error.java +++ b/Samples/1b-code-generation-multilang/Java/models/Error.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package javanamespace.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Error model. - */ -public class Error { - /** - * The code property. - */ - @JsonProperty(value = "code", required = true) - private int code; - - /** - * The message property. - */ - @JsonProperty(value = "message", required = true) - private String message; - - /** - * Get the code value. - * - * @return the code value - */ - public int code() { - return this.code; - } - - /** - * Set the code value. - * - * @param code the code value to set - * @return the Error object itself. - */ - public Error withCode(int code) { - this.code = code; - return this; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } - - /** - * Set the message value. - * - * @param message the message value to set - * @return the Error object itself. - */ - public Error withMessage(String message) { - this.message = message; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/models/ErrorException.java b/Samples/1b-code-generation-multilang/Java/models/ErrorException.java index 0d99a1003..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/models/ErrorException.java +++ b/Samples/1b-code-generation-multilang/Java/models/ErrorException.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package javanamespace.models; - -import com.microsoft.rest.RestException; -import okhttp3.ResponseBody; -import retrofit2.Response; - -/** - * Exception thrown for an invalid response with Error information. - */ -public class ErrorException extends RestException { - /** - * Initializes a new instance of the ErrorException class. - * - * @param message the exception message or the response content if a message is not available - * @param response the HTTP response - */ - public ErrorException(final String message, final Response response) { - super(message, response); - } - - /** - * Initializes a new instance of the ErrorException class. - * - * @param message the exception message or the response content if a message is not available - * @param response the HTTP response - * @param body the deserialized response body - */ - public ErrorException(final String message, final Response response, final Error body) { - super(message, response, body); - } - - @Override - public Error body() { - return (Error) super.body(); - } -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/models/ListPetsHeaders.java b/Samples/1b-code-generation-multilang/Java/models/ListPetsHeaders.java index f3f387f88..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/models/ListPetsHeaders.java +++ b/Samples/1b-code-generation-multilang/Java/models/ListPetsHeaders.java @@ -1,41 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package javanamespace.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Defines headers for listPets operation. - */ -public class ListPetsHeaders { - /** - * A link to the next page of responses. - */ - @JsonProperty(value = "x-next") - private String xNext; - - /** - * Get the xNext value. - * - * @return the xNext value - */ - public String xNext() { - return this.xNext; - } - - /** - * Set the xNext value. - * - * @param xNext the xNext value to set - * @return the ListPetsHeaders object itself. - */ - public ListPetsHeaders withXNext(String xNext) { - this.xNext = xNext; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/models/Pet.java b/Samples/1b-code-generation-multilang/Java/models/Pet.java index 02e24d767..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/models/Pet.java +++ b/Samples/1b-code-generation-multilang/Java/models/Pet.java @@ -1,93 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package javanamespace.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Pet model. - */ -public class Pet { - /** - * The id property. - */ - @JsonProperty(value = "id", required = true) - private long id; - - /** - * The name property. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * The tag property. - */ - @JsonProperty(value = "tag") - private String tag; - - /** - * Get the id value. - * - * @return the id value - */ - public long id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the Pet object itself. - */ - public Pet withId(long id) { - this.id = id; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Pet object itself. - */ - public Pet withName(String name) { - this.name = name; - return this; - } - - /** - * Get the tag value. - * - * @return the tag value - */ - public String tag() { - return this.tag; - } - - /** - * Set the tag value. - * - * @param tag the tag value to set - * @return the Pet object itself. - */ - public Pet withTag(String tag) { - this.tag = tag; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/models/package-info.java b/Samples/1b-code-generation-multilang/Java/models/package-info.java index ab11c5439..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/models/package-info.java +++ b/Samples/1b-code-generation-multilang/Java/models/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the models classes for SwaggerPetstore. - */ -package javanamespace.models; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Java/package-info.java b/Samples/1b-code-generation-multilang/Java/package-info.java index 90d4a930b..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Java/package-info.java +++ b/Samples/1b-code-generation-multilang/Java/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the classes for SwaggerPetstore. - */ -package javanamespace; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/NodeJS/models/errorModel.js b/Samples/1b-code-generation-multilang/NodeJS/models/errorModel.js index e091c9143..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/NodeJS/models/errorModel.js +++ b/Samples/1b-code-generation-multilang/NodeJS/models/errorModel.js @@ -1,55 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * Class representing a ErrorModel. - */ -class ErrorModel { - /** - * Create a ErrorModel. - * @member {number} code - * @member {string} message - */ - constructor() { - } - - /** - * Defines the metadata of ErrorModel - * - * @returns {object} metadata of ErrorModel - * - */ - mapper() { - return { - required: false, - serializedName: 'Error', - type: { - name: 'Composite', - className: 'ErrorModel', - modelProperties: { - code: { - required: true, - serializedName: 'code', - type: { - name: 'Number' - } - }, - message: { - required: true, - serializedName: 'message', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = ErrorModel; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/NodeJS/models/index.js b/Samples/1b-code-generation-multilang/NodeJS/models/index.js index 2f9f8cab2..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/NodeJS/models/index.js +++ b/Samples/1b-code-generation-multilang/NodeJS/models/index.js @@ -1,14 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -exports.Pet = require('./pet'); -exports.ErrorModel = require('./errorModel'); +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/NodeJS/models/pet.js b/Samples/1b-code-generation-multilang/NodeJS/models/pet.js index 07e34cbe6..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/NodeJS/models/pet.js +++ b/Samples/1b-code-generation-multilang/NodeJS/models/pet.js @@ -1,63 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * Class representing a Pet. - */ -class Pet { - /** - * Create a Pet. - * @member {number} id - * @member {string} name - * @member {string} [tag] - */ - constructor() { - } - - /** - * Defines the metadata of Pet - * - * @returns {object} metadata of Pet - * - */ - mapper() { - return { - required: false, - serializedName: 'Pet', - type: { - name: 'Composite', - className: 'Pet', - modelProperties: { - id: { - required: true, - serializedName: 'id', - type: { - name: 'Number' - } - }, - name: { - required: true, - serializedName: 'name', - type: { - name: 'String' - } - }, - tag: { - required: false, - serializedName: 'tag', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = Pet; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/NodeJS/swaggerPetstore.js b/Samples/1b-code-generation-multilang/NodeJS/swaggerPetstore.js index 143e1240d..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/NodeJS/swaggerPetstore.js +++ b/Samples/1b-code-generation-multilang/NodeJS/swaggerPetstore.js @@ -1,656 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -const msRest = require('ms-rest'); -const ServiceClient = msRest.ServiceClient; -const WebResource = msRest.WebResource; - -const models = require('./models'); - - -/** - * @summary List all pets - * - * @param {object} [options] Optional Parameters. - * - * @param {number} [options.limit] How many items to return at one time (max - * 100) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _listPets(options, callback) { - /* jshint validthis: true */ - let client = this; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - let limit = (options && options.limit !== undefined) ? options.limit : undefined; - // Validate - try { - if (limit !== null && limit !== undefined && typeof limit !== 'number') { - throw new Error('limit must be of type number.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'pets'; - let queryParameters = []; - if (limit !== null && limit !== undefined) { - queryParameters.push('limit=' + encodeURIComponent(limit.toString())); - } - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorModel']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = { - required: false, - serializedName: 'parsedResponse', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'PetElementType', - type: { - name: 'Composite', - className: 'Pet' - } - } - } - }; - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @summary Create a pet - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _createPets(options, callback) { - /* jshint validthis: true */ - let client = this; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - - // Construct URL - let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'pets'; - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 201) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorModel']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @summary Info for a specific pet - * - * @param {string} petId The id of the pet to retrieve - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _showPetById(petId, options, callback) { - /* jshint validthis: true */ - let client = this; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - // Validate - try { - if (petId === null || petId === undefined || typeof petId.valueOf() !== 'string') { - throw new Error('petId 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('/') ? '' : '/') + 'pets/{petId}'; - requestUrl = requestUrl.replace('{petId}', encodeURIComponent(petId)); - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorModel']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = { - required: false, - serializedName: 'parsedResponse', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'PetElementType', - type: { - name: 'Composite', - className: 'Pet' - } - } - } - }; - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a SwaggerPetstore. */ -class SwaggerPetstore extends ServiceClient { - /** - * Create a SwaggerPetstore. - * @param {string} [baseUri] - The base URI of the service. - * @param {object} [options] - The parameter options - * @param {Array} [options.filters] - Filters to be added to the request pipeline - * @param {object} [options.requestOptions] - Options for the underlying request object - * {@link https://github.com/request/request#requestoptions-callback Options doc} - * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy - */ - constructor(baseUri, options) { - - if (!options) options = {}; - - super(null, options); - - this.baseUri = baseUri; - if (!this.baseUri) { - this.baseUri = 'http://petstore.swagger.io/v1'; - } - - let packageInfo = this.getPackageJsonInfo(__dirname); - this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); - this.models = models; - this._listPets = _listPets; - this._createPets = _createPets; - this._showPetById = _showPetById; - msRest.addSerializationMixin(this); - } - - /** - * @summary List all pets - * - * @param {object} [options] Optional Parameters. - * - * @param {number} [options.limit] How many items to return at one time (max - * 100) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - listPetsWithHttpOperationResponse(options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._listPets(options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary List all pets - * - * @param {object} [options] Optional Parameters. - * - * @param {number} [options.limit] How many items to return at one time (max - * 100) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {Array} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - listPets(options, optionalCallback) { - let client = this; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._listPets(options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._listPets(options, optionalCallback); - } - } - - /** - * @summary Create a pet - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - createPetsWithHttpOperationResponse(options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._createPets(options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary Create a pet - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - createPets(options, optionalCallback) { - let client = this; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._createPets(options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._createPets(options, optionalCallback); - } - } - - /** - * @summary Info for a specific pet - * - * @param {string} petId The id of the pet to retrieve - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - showPetByIdWithHttpOperationResponse(petId, options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._showPetById(petId, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary Info for a specific pet - * - * @param {string} petId The id of the pet to retrieve - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {Array} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {array} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - showPetById(petId, options, optionalCallback) { - let client = this; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._showPetById(petId, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._showPetById(petId, options, optionalCallback); - } - } - -} - -module.exports = SwaggerPetstore; +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Ruby/generated/petstore.rb b/Samples/1b-code-generation-multilang/Ruby/generated/petstore.rb index f668a0a9d..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Ruby/generated/petstore.rb +++ b/Samples/1b-code-generation-multilang/Ruby/generated/petstore.rb @@ -1,28 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -require 'uri' -require 'cgi' -require 'date' -require 'json' -require 'base64' -require 'erb' -require 'securerandom' -require 'time' -require 'timeliness' -require 'faraday' -require 'faraday-cookie_jar' -require 'concurrent' -require 'ms_rest' -require 'generated/petstore/module_definition' - -module cowstore - autoload :SwaggerPetstore, 'generated/petstore/swagger_petstore.rb' - - module Models - autoload :Pet, 'generated/petstore/models/pet.rb' - autoload :Error, 'generated/petstore/models/error.rb' - end -end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/error.rb b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/error.rb index a20d0d2cc..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/error.rb +++ b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/error.rb @@ -1,52 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore - module Models - # - # Model object. - # - # - class Error - # @return [Integer] - attr_accessor :code - - # @return [String] - attr_accessor :message - - - # - # Mapper for Error class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Error', - type: { - name: 'Composite', - class_name: 'Error', - model_properties: { - code: { - required: true, - serialized_name: 'code', - type: { - name: 'Number' - } - }, - message: { - required: true, - serialized_name: 'message', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/pet.rb b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/pet.rb index 55543fbad..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/pet.rb +++ b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/models/pet.rb @@ -1,62 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore - module Models - # - # Model object. - # - # - class Pet - # @return [Integer] - attr_accessor :id - - # @return [String] - attr_accessor :name - - # @return [String] - attr_accessor :tag - - - # - # Mapper for Pet class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Pet', - type: { - name: 'Composite', - class_name: 'Pet', - model_properties: { - id: { - required: true, - serialized_name: 'id', - type: { - name: 'Number' - } - }, - name: { - required: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - tag: { - required: false, - serialized_name: 'tag', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/module_definition.rb b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/module_definition.rb index 3c2f8703f..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/module_definition.rb +++ b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/module_definition.rb @@ -1,6 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore end +SRC \ No newline at end of file diff --git a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/swagger_petstore.rb b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/swagger_petstore.rb index b27d2e6d4..9d6cafc2c 100644 --- a/Samples/1b-code-generation-multilang/Ruby/generated/petstore/swagger_petstore.rb +++ b/Samples/1b-code-generation-multilang/Ruby/generated/petstore/swagger_petstore.rb @@ -1,347 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module cowstore - # - # A service client - single point of access to the REST API. - # - class SwaggerPetstore < MsRest::ServiceClient - include MsRest::Serialization - - # @return [String] the base URI of the service. - attr_accessor :base_url - - # - # Creates initializes a new instance of the SwaggerPetstore class. - # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. - # @param base_url [String] the base URI of the service. - # @param options [Array] filters to be applied to the HTTP requests. - # - def initialize(credentials = nil, base_url = nil, options = nil) - super(credentials, options) - @base_url = base_url || 'http://petstore.swagger.io/v1' - - fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? - @credentials = credentials - - add_telemetry - end - - # - # Makes a request and returns the body of the response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Hash{String=>String}] containing the body of the response. - # Example: - # - # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}" - # path = "/path" - # options = { - # body: request_content, - # query_params: {'api-version' => '2016-02-01'} - # } - # result = @client.make_request(:put, path, options) - # - def make_request(method, path, options = {}) - result = make_request_with_http_info(method, path, options) - result.body unless result.nil? - end - - # - # Makes a request and returns the operation response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [MsRest::HttpOperationResponse] Operation response containing the request, response and status. - # - def make_request_with_http_info(method, path, options = {}) - result = make_request_async(method, path, options).value! - result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body) - result - end - - # - # Makes a request asynchronously. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def make_request_async(method, path, options = {}) - fail ArgumentError, 'method is nil' if method.nil? - fail ArgumentError, 'path is nil' if path.nil? - - request_url = options[:base_url] || @base_url - - request_headers = @request_headers - options.merge!({headers: request_headers.merge(options[:headers] || {})}) - options.merge!({credentials: @credentials}) unless @credentials.nil? - - super(request_url, method, path, options) - end - - # - # List all pets - # - # @param limit [Integer] How many items to return at one time (max 100) - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Array] operation results. - # - def list_pets(limit = nil, custom_headers = nil) - response = list_pets_async(limit, custom_headers).value! - response.body unless response.nil? - end - - # - # List all pets - # - # @param limit [Integer] How many items to return at one time (max 100) - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_pets_with_http_info(limit = nil, custom_headers = nil) - list_pets_async(limit, custom_headers).value! - end - - # - # List all pets - # - # @param limit [Integer] How many items to return at one time (max 100) - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_pets_async(limit = nil, custom_headers = nil) - - - request_headers = {} - path_template = 'pets' - - request_url = @base_url || self.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - query_params: {'limit' => limit}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = self.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = { - required: false, - serialized_name: 'parsed_response', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'PetElementType', - type: { - name: 'Composite', - class_name: 'Pet' - } - } - } - } - result.body = self.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Create a pet - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def create_pets(custom_headers = nil) - response = create_pets_async(custom_headers).value! - nil - end - - # - # Create a pet - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def create_pets_with_http_info(custom_headers = nil) - create_pets_async(custom_headers).value! - end - - # - # Create a pet - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def create_pets_async(custom_headers = nil) - - - request_headers = {} - path_template = 'pets' - - request_url = @base_url || self.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = self.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 201 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # Info for a specific pet - # - # @param pet_id [String] The id of the pet to retrieve - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Array] operation results. - # - def show_pet_by_id(pet_id, custom_headers = nil) - response = show_pet_by_id_async(pet_id, custom_headers).value! - response.body unless response.nil? - end - - # - # Info for a specific pet - # - # @param pet_id [String] The id of the pet to retrieve - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def show_pet_by_id_with_http_info(pet_id, custom_headers = nil) - show_pet_by_id_async(pet_id, custom_headers).value! - end - - # - # Info for a specific pet - # - # @param pet_id [String] The id of the pet to retrieve - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def show_pet_by_id_async(pet_id, custom_headers = nil) - fail ArgumentError, 'pet_id is nil' if pet_id.nil? - - - request_headers = {} - path_template = 'pets/{petId}' - - request_url = @base_url || self.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'petId' => pet_id}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = self.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = { - required: false, - serialized_name: 'parsed_response', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'PetElementType', - type: { - name: 'Composite', - class_name: 'Pet' - } - } - } - } - result.body = self.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - - private - # - # Adds telemetry information. - # - def add_telemetry - sdk_information = 'petstore' - if defined? cowstore::VERSION - sdk_information = "#{sdk_information}/#{cowstore::VERSION}" - end - add_user_agent_information(sdk_information) - end - end -end +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/DataSources.cs b/Samples/1c-multiple-input-swaggers/Client/DataSources.cs index 82244eb35..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/DataSources.cs +++ b/Samples/1c-multiple-input-swaggers/Client/DataSources.cs @@ -1,879 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// DataSources operations. - /// - public partial class DataSources : IServiceOperations, IDataSources - { - /// - /// Initializes a new instance of the DataSources class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public DataSources(SearchandStorage client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SearchandStorage - /// - public SearchandStorage Client { get; private set; } - - /// - /// Creates a new Azure Search datasource or updates a datasource if it already - /// exists. - /// - /// - /// - /// The name of the datasource to create or update. - /// - /// - /// The definition of the datasource to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (dataSourceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "dataSourceName"); - } - if (dataSource == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "dataSource"); - } - if (dataSource != null) - { - dataSource.Validate(); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("dataSourceName", dataSourceName); - tracingParameters.Add("dataSource", dataSource); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "datasources('{dataSourceName}')").ToString(); - _url = _url.Replace("{dataSourceName}", System.Uri.EscapeDataString(dataSourceName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(dataSource != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(dataSource, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes an Azure Search datasource. - /// - /// - /// - /// The name of the datasource to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (dataSourceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "dataSourceName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("dataSourceName", dataSourceName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "datasources('{dataSourceName}')").ToString(); - _url = _url.Replace("{dataSourceName}", System.Uri.EscapeDataString(dataSourceName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Retrieves a datasource definition from Azure Search. - /// - /// - /// - /// The name of the datasource to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (dataSourceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "dataSourceName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("dataSourceName", dataSourceName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "datasources('{dataSourceName}')").ToString(); - _url = _url.Replace("{dataSourceName}", System.Uri.EscapeDataString(dataSourceName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all datasources available for an Azure Search service. - /// - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "datasources").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates a new Azure Search datasource. - /// - /// - /// - /// The definition of the datasource to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateWithHttpMessagesAsync(DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (dataSource == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "dataSource"); - } - if (dataSource != null) - { - dataSource.Validate(); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("dataSource", dataSource); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "datasources").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(dataSource != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(dataSource, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/DataSourcesExtensions.cs b/Samples/1c-multiple-input-swaggers/Client/DataSourcesExtensions.cs index 97bf07493..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/DataSourcesExtensions.cs +++ b/Samples/1c-multiple-input-swaggers/Client/DataSourcesExtensions.cs @@ -1,228 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for DataSources. - /// - public static partial class DataSourcesExtensions - { - /// - /// Creates a new Azure Search datasource or updates a datasource if it already - /// exists. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the datasource to create or update. - /// - /// - /// The definition of the datasource to create or update. - /// - /// - /// Additional parameters for the operation - /// - public static DataSource CreateOrUpdate(this IDataSources operations, string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.CreateOrUpdateAsync(dataSourceName, dataSource, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Azure Search datasource or updates a datasource if it already - /// exists. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the datasource to create or update. - /// - /// - /// The definition of the datasource to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IDataSources operations, string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(dataSourceName, dataSource, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes an Azure Search datasource. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the datasource to delete. - /// - /// - /// Additional parameters for the operation - /// - public static void Delete(this IDataSources operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - operations.DeleteAsync(dataSourceName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Deletes an Azure Search datasource. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the datasource to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IDataSources operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(dataSourceName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Retrieves a datasource definition from Azure Search. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the datasource to retrieve. - /// - /// - /// Additional parameters for the operation - /// - public static DataSource Get(this IDataSources operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.GetAsync(dataSourceName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Retrieves a datasource definition from Azure Search. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the datasource to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IDataSources operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(dataSourceName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all datasources available for an Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// Additional parameters for the operation - /// - public static DataSourceListResult List(this IDataSources operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.ListAsync(searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Lists all datasources available for an Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IDataSources operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates a new Azure Search datasource. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the datasource to create. - /// - /// - /// Additional parameters for the operation - /// - public static DataSource Create(this IDataSources operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.CreateAsync(dataSource, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Azure Search datasource. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the datasource to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IDataSources operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(dataSource, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/IDataSources.cs b/Samples/1c-multiple-input-swaggers/Client/IDataSources.cs index 4f25232bc..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/IDataSources.cs +++ b/Samples/1c-multiple-input-swaggers/Client/IDataSources.cs @@ -1,150 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// DataSources operations. - /// - public partial interface IDataSources - { - /// - /// Creates a new Azure Search datasource or updates a datasource if it - /// already exists. - /// - /// - /// - /// The name of the datasource to create or update. - /// - /// - /// The definition of the datasource to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes an Azure Search datasource. - /// - /// - /// - /// The name of the datasource to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Retrieves a datasource definition from Azure Search. - /// - /// - /// - /// The name of the datasource to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all datasources available for an Azure Search service. - /// - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates a new Azure Search datasource. - /// - /// - /// - /// The definition of the datasource to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/IIndexers.cs b/Samples/1c-multiple-input-swaggers/Client/IIndexers.cs index 79b93b133..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/IIndexers.cs +++ b/Samples/1c-multiple-input-swaggers/Client/IIndexers.cs @@ -1,223 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Indexers operations. - /// - public partial interface IIndexers - { - /// - /// Resets the change tracking state associated with an Azure Search - /// indexer. - /// - /// - /// - /// The name of the indexer to reset. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task ResetWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Runs an Azure Search indexer on-demand. - /// - /// - /// - /// The name of the indexer to run. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task RunWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates a new Azure Search indexer or updates an indexer if it - /// already exists. - /// - /// - /// - /// The name of the indexer to create or update. - /// - /// - /// The definition of the indexer to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string indexerName, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes an Azure Search indexer. - /// - /// - /// - /// The name of the indexer to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Retrieves an indexer definition from Azure Search. - /// - /// - /// - /// The name of the indexer to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all indexers available for an Azure Search service. - /// - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates a new Azure Search indexer. - /// - /// - /// - /// The definition of the indexer to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the current status and execution history of an indexer. - /// - /// - /// - /// The name of the indexer for which to retrieve status. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetStatusWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/IIndexes.cs b/Samples/1c-multiple-input-swaggers/Client/IIndexes.cs index bf5487290..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/IIndexes.cs +++ b/Samples/1c-multiple-input-swaggers/Client/IIndexes.cs @@ -1,182 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Indexes operations. - /// - public partial interface IIndexes - { - /// - /// Creates a new Azure Search index. - /// - /// - /// - /// The definition of the index to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all indexes available for an Azure Search service. - /// - /// - /// - /// Selects which properties of the index definitions to retrieve. - /// Specified as a comma-separated list of JSON property names, or '*' - /// for all properties. The default is all properties. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates a new Azure Search index or updates an index if it already - /// exists. - /// - /// - /// - /// The definition of the index to create or update. - /// - /// - /// The definition of the index to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string indexName, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes an Azure Search index and all the documents it contains. - /// - /// - /// - /// The name of the index to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Retrieves an index definition from Azure Search. - /// - /// - /// - /// The name of the index to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns statistics for the given index, including a document count - /// and storage usage. - /// - /// - /// - /// The name of the index for which to retrieve statistics. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetStatisticsWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/ISearchandStorage.cs b/Samples/1c-multiple-input-swaggers/Client/ISearchandStorage.cs index c4b2dd0f5..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/ISearchandStorage.cs +++ b/Samples/1c-multiple-input-swaggers/Client/ISearchandStorage.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Models; - using Newtonsoft.Json; - - /// - /// - public partial interface ISearchandStorage : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - - /// - /// Gets the IDataSources. - /// - IDataSources DataSources { get; } - - /// - /// Gets the IIndexers. - /// - IIndexers Indexers { get; } - - /// - /// Gets the IIndexes. - /// - IIndexes Indexes { get; } - - /// - /// Gets the IStorageAccounts. - /// - IStorageAccounts StorageAccounts { get; } - - /// - /// Gets the IUsageOperations. - /// - IUsageOperations Usage { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/IStorageAccounts.cs b/Samples/1c-multiple-input-swaggers/Client/IStorageAccounts.cs index 549f0c707..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/IStorageAccounts.cs +++ b/Samples/1c-multiple-input-swaggers/Client/IStorageAccounts.cs @@ -1,278 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial interface IStorageAccounts - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one - /// property can be changed at a time using this API. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 - /// for the default keys - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/IUsageOperations.cs b/Samples/1c-multiple-input-swaggers/Client/IUsageOperations.cs index edfe3b63c..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/IUsageOperations.cs +++ b/Samples/1c-multiple-input-swaggers/Client/IUsageOperations.cs @@ -1,42 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial interface IUsageOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Indexers.cs b/Samples/1c-multiple-input-swaggers/Client/Indexers.cs index dcdfce055..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Indexers.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Indexers.cs @@ -1,1329 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Indexers operations. - /// - public partial class Indexers : IServiceOperations, IIndexers - { - /// - /// Initializes a new instance of the Indexers class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Indexers(SearchandStorage client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SearchandStorage - /// - public SearchandStorage Client { get; private set; } - - /// - /// Resets the change tracking state associated with an Azure Search indexer. - /// - /// - /// - /// The name of the indexer to reset. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task ResetWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexerName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexerName", indexerName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Reset", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers('{indexerName}')/search.reset").ToString(); - _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Runs an Azure Search indexer on-demand. - /// - /// - /// - /// The name of the indexer to run. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task RunWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexerName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexerName", indexerName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Run", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers('{indexerName}')/search.run").ToString(); - _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates a new Azure Search indexer or updates an indexer if it already - /// exists. - /// - /// - /// - /// The name of the indexer to create or update. - /// - /// - /// The definition of the indexer to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string indexerName, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexerName"); - } - if (indexer == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexer"); - } - if (indexer != null) - { - indexer.Validate(); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexerName", indexerName); - tracingParameters.Add("indexer", indexer); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers('{indexerName}')").ToString(); - _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(indexer != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(indexer, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes an Azure Search indexer. - /// - /// - /// - /// The name of the indexer to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexerName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexerName", indexerName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers('{indexerName}')").ToString(); - _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 204) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Retrieves an indexer definition from Azure Search. - /// - /// - /// - /// The name of the indexer to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexerName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexerName", indexerName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers('{indexerName}')").ToString(); - _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all indexers available for an Azure Search service. - /// - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates a new Azure Search indexer. - /// - /// - /// - /// The definition of the indexer to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateWithHttpMessagesAsync(Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexer == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexer"); - } - if (indexer != null) - { - indexer.Validate(); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexer", indexer); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(indexer != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(indexer, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the current status and execution history of an indexer. - /// - /// - /// - /// The name of the indexer for which to retrieve status. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetStatusWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexerName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexerName", indexerName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetStatus", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexers('{indexerName}')/search.status").ToString(); - _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/IndexersExtensions.cs b/Samples/1c-multiple-input-swaggers/Client/IndexersExtensions.cs index f63ff0476..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/IndexersExtensions.cs +++ b/Samples/1c-multiple-input-swaggers/Client/IndexersExtensions.cs @@ -1,348 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Indexers. - /// - public static partial class IndexersExtensions - { - /// - /// Resets the change tracking state associated with an Azure Search indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to reset. - /// - /// - /// Additional parameters for the operation - /// - public static void Reset(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - operations.ResetAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Resets the change tracking state associated with an Azure Search indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to reset. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task ResetAsync(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.ResetWithHttpMessagesAsync(indexerName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Runs an Azure Search indexer on-demand. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to run. - /// - /// - /// Additional parameters for the operation - /// - public static void Run(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - operations.RunAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Runs an Azure Search indexer on-demand. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to run. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task RunAsync(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.RunWithHttpMessagesAsync(indexerName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates a new Azure Search indexer or updates an indexer if it already - /// exists. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to create or update. - /// - /// - /// The definition of the indexer to create or update. - /// - /// - /// Additional parameters for the operation - /// - public static Indexer CreateOrUpdate(this IIndexers operations, string indexerName, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.CreateOrUpdateAsync(indexerName, indexer, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Azure Search indexer or updates an indexer if it already - /// exists. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to create or update. - /// - /// - /// The definition of the indexer to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IIndexers operations, string indexerName, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(indexerName, indexer, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes an Azure Search indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to delete. - /// - /// - /// Additional parameters for the operation - /// - public static void Delete(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - operations.DeleteAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Deletes an Azure Search indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(indexerName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Retrieves an indexer definition from Azure Search. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to retrieve. - /// - /// - /// Additional parameters for the operation - /// - public static Indexer Get(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.GetAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Retrieves an indexer definition from Azure Search. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(indexerName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all indexers available for an Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// Additional parameters for the operation - /// - public static IndexerListResult List(this IIndexers operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.ListAsync(searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Lists all indexers available for an Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IIndexers operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates a new Azure Search indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the indexer to create. - /// - /// - /// Additional parameters for the operation - /// - public static Indexer Create(this IIndexers operations, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.CreateAsync(indexer, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Azure Search indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the indexer to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IIndexers operations, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(indexer, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Returns the current status and execution history of an indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer for which to retrieve status. - /// - /// - /// Additional parameters for the operation - /// - public static IndexerExecutionInfo GetStatus(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.GetStatusAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Returns the current status and execution history of an indexer. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the indexer for which to retrieve status. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task GetStatusAsync(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetStatusWithHttpMessagesAsync(indexerName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Indexes.cs b/Samples/1c-multiple-input-swaggers/Client/Indexes.cs index f4933ff3a..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Indexes.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Indexes.cs @@ -1,1053 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Indexes operations. - /// - public partial class Indexes : IServiceOperations, IIndexes - { - /// - /// Initializes a new instance of the Indexes class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Indexes(SearchandStorage client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SearchandStorage - /// - public SearchandStorage Client { get; private set; } - - /// - /// Creates a new Azure Search index. - /// - /// - /// - /// The definition of the index to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateWithHttpMessagesAsync(Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (index == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "index"); - } - if (index != null) - { - index.Validate(); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("index", index); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexes").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(index != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(index, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all indexes available for an Azure Search service. - /// - /// - /// - /// Selects which properties of the index definitions to retrieve. Specified as - /// a comma-separated list of JSON property names, or '*' for all properties. - /// The default is all properties. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("select", select); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexes").ToString(); - List _queryParameters = new List(); - if (select != null) - { - _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); - } - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates a new Azure Search index or updates an index if it already exists. - /// - /// - /// - /// The definition of the index to create or update. - /// - /// - /// The definition of the index to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string indexName, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexName"); - } - if (index == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "index"); - } - if (index != null) - { - index.Validate(); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexName", indexName); - tracingParameters.Add("index", index); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexes('{indexName}')").ToString(); - _url = _url.Replace("{indexName}", System.Uri.EscapeDataString(indexName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(index != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(index, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes an Azure Search index and all the documents it contains. - /// - /// - /// - /// The name of the index to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexName", indexName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexes('{indexName}')").ToString(); - _url = _url.Replace("{indexName}", System.Uri.EscapeDataString(indexName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Retrieves an index definition from Azure Search. - /// - /// - /// - /// The name of the index to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexName", indexName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexes('{indexName}')").ToString(); - _url = _url.Replace("{indexName}", System.Uri.EscapeDataString(indexName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns statistics for the given index, including a document count and - /// storage usage. - /// - /// - /// - /// The name of the index for which to retrieve statistics. - /// - /// - /// Additional parameters for the operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetStatisticsWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (indexName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "indexName"); - } - string apiVersion = "2015-02-28"; - System.Guid? clientRequestId = default(System.Guid?); - if (searchRequestOptions != null) - { - clientRequestId = searchRequestOptions.ClientRequestId; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("indexName", indexName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("clientRequestId", clientRequestId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetStatistics", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexes('{indexName}')/search.stats").ToString(); - _url = _url.Replace("{indexName}", System.Uri.EscapeDataString(indexName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (clientRequestId != null) - { - if (_httpRequest.Headers.Contains("client-request-id")) - { - _httpRequest.Headers.Remove("client-request-id"); - } - _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/IndexesExtensions.cs b/Samples/1c-multiple-input-swaggers/Client/IndexesExtensions.cs index f8bbc9ac2..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/IndexesExtensions.cs +++ b/Samples/1c-multiple-input-swaggers/Client/IndexesExtensions.cs @@ -1,280 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Indexes. - /// - public static partial class IndexesExtensions - { - /// - /// Creates a new Azure Search index. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the index to create. - /// - /// - /// Additional parameters for the operation - /// - public static Index Create(this IIndexes operations, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.CreateAsync(index, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Azure Search index. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the index to create. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IIndexes operations, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(index, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all indexes available for an Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// Selects which properties of the index definitions to retrieve. Specified as - /// a comma-separated list of JSON property names, or '*' for all properties. - /// The default is all properties. - /// - /// - /// Additional parameters for the operation - /// - public static IndexListResult List(this IIndexes operations, string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.ListAsync(select, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Lists all indexes available for an Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// Selects which properties of the index definitions to retrieve. Specified as - /// a comma-separated list of JSON property names, or '*' for all properties. - /// The default is all properties. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IIndexes operations, string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(select, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates a new Azure Search index or updates an index if it already exists. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the index to create or update. - /// - /// - /// The definition of the index to create or update. - /// - /// - /// Additional parameters for the operation - /// - public static Index CreateOrUpdate(this IIndexes operations, string indexName, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.CreateOrUpdateAsync(indexName, index, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Azure Search index or updates an index if it already exists. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The definition of the index to create or update. - /// - /// - /// The definition of the index to create or update. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IIndexes operations, string indexName, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(indexName, index, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes an Azure Search index and all the documents it contains. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the index to delete. - /// - /// - /// Additional parameters for the operation - /// - public static void Delete(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - operations.DeleteAsync(indexName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Deletes an Azure Search index and all the documents it contains. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the index to delete. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(indexName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Retrieves an index definition from Azure Search. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the index to retrieve. - /// - /// - /// Additional parameters for the operation - /// - public static Index Get(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.GetAsync(indexName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Retrieves an index definition from Azure Search. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the index to retrieve. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(indexName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Returns statistics for the given index, including a document count and - /// storage usage. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the index for which to retrieve statistics. - /// - /// - /// Additional parameters for the operation - /// - public static IndexGetStatisticsResult GetStatistics(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) - { - return operations.GetStatisticsAsync(indexName, searchRequestOptions).GetAwaiter().GetResult(); - } - - /// - /// Returns statistics for the given index, including a document count and - /// storage usage. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the index for which to retrieve statistics. - /// - /// - /// Additional parameters for the operation - /// - /// - /// The cancellation token. - /// - public static async Task GetStatisticsAsync(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetStatisticsWithHttpMessagesAsync(indexName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/AccountStatus.cs b/Samples/1c-multiple-input-swaggers/Client/Models/AccountStatus.cs index a98ab3341..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/AccountStatus.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/AccountStatus.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/AccountType.cs b/Samples/1c-multiple-input-swaggers/Client/Models/AccountType.cs index cbf615896..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/AccountType.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/AccountType.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/CheckNameAvailabilityResult.cs b/Samples/1c-multiple-input-swaggers/Client/Models/CheckNameAvailabilityResult.cs index 1ee967b98..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/CheckNameAvailabilityResult.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/CheckNameAvailabilityResult.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/CorsOptions.cs b/Samples/1c-multiple-input-swaggers/Client/Models/CorsOptions.cs index ade349428..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/CorsOptions.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/CorsOptions.cs @@ -1,83 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Defines options to control Cross-Origin Resource Sharing (CORS) for an - /// index. - /// - /// - public partial class CorsOptions - { - /// - /// Initializes a new instance of the CorsOptions class. - /// - public CorsOptions() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CorsOptions class. - /// - /// Gets the list of origins from which - /// JavaScript code will be granted access to your index. Can contain a - /// list of hosts of the form - /// {protocol}://{fully-qualified-domain-name}[:{port#}], or a single - /// '*' to allow all origins (not recommended). - /// Gets or sets the duration for which - /// browsers should cache CORS preflight responses. Defaults to 5 - /// mintues. - public CorsOptions(IList allowedOrigins, long? maxAgeInSeconds = default(long?)) - { - AllowedOrigins = allowedOrigins; - MaxAgeInSeconds = maxAgeInSeconds; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of origins from which JavaScript code will be granted - /// access to your index. Can contain a list of hosts of the form - /// {protocol}://{fully-qualified-domain-name}[:{port#}], or a single - /// '*' to allow all origins (not recommended). - /// - [JsonProperty(PropertyName = "allowedOrigins")] - public IList AllowedOrigins { get; set; } - - /// - /// Gets or sets the duration for which browsers should cache CORS - /// preflight responses. Defaults to 5 mintues. - /// - [JsonProperty(PropertyName = "maxAgeInSeconds")] - public long? MaxAgeInSeconds { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (AllowedOrigins == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "AllowedOrigins"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/CustomDomain.cs b/Samples/1c-multiple-input-swaggers/Client/Models/CustomDomain.cs index 46d73084b..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/CustomDomain.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/CustomDomain.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/DataChangeDetectionPolicy.cs b/Samples/1c-multiple-input-swaggers/Client/Models/DataChangeDetectionPolicy.cs index 2f088766d..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/DataChangeDetectionPolicy.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/DataChangeDetectionPolicy.cs @@ -1,31 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using System.Linq; - - /// - /// Abstract base class for data change detection policies. - /// - public partial class DataChangeDetectionPolicy - { - /// - /// Initializes a new instance of the DataChangeDetectionPolicy class. - /// - public DataChangeDetectionPolicy() - { - CustomInit(); - } - - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/DataContainer.cs b/Samples/1c-multiple-input-swaggers/Client/Models/DataContainer.cs index 2b17c5440..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/DataContainer.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/DataContainer.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Represents information about the entity (such as Azure SQL table or - /// DocumentDb collection) that will be indexed. - /// - public partial class DataContainer - { - /// - /// Initializes a new instance of the DataContainer class. - /// - public DataContainer() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the DataContainer class. - /// - /// Gets or sets the name of the table or view (for - /// Azure SQL data source) or collection (for DocumentDB data source) - /// that will be indexed. - /// Gets or sets a query that is applied to this - /// data container. Only supported by DocumentDb datasources. - public DataContainer(string name, string query = default(string)) - { - Name = name; - Query = query; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the table or view (for Azure SQL data - /// source) or collection (for DocumentDB data source) that will be - /// indexed. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a query that is applied to this data container. Only - /// supported by DocumentDb datasources. - /// - [JsonProperty(PropertyName = "query")] - public string Query { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/DataDeletionDetectionPolicy.cs b/Samples/1c-multiple-input-swaggers/Client/Models/DataDeletionDetectionPolicy.cs index 4c95ebc18..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/DataDeletionDetectionPolicy.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/DataDeletionDetectionPolicy.cs @@ -1,32 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using System.Linq; - - /// - /// Abstract base class for data deletion detection policies. - /// - public partial class DataDeletionDetectionPolicy - { - /// - /// Initializes a new instance of the DataDeletionDetectionPolicy - /// class. - /// - public DataDeletionDetectionPolicy() - { - CustomInit(); - } - - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/DataSource.cs b/Samples/1c-multiple-input-swaggers/Client/Models/DataSource.cs index 3205349dd..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/DataSource.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/DataSource.cs @@ -1,135 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Represents a datasource definition in Azure Search, which can be used - /// to configure an indexer. - /// - public partial class DataSource - { - /// - /// Initializes a new instance of the DataSource class. - /// - public DataSource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the DataSource class. - /// - /// Gets or sets the name of the datasource. - /// Gets or sets the type of the datasource. - /// Gets or sets credentials for the - /// datasource. - /// Gets or sets the data container for the - /// datasource. - /// Gets or sets the description of the - /// datasource. - /// Gets or sets the data - /// change detection policy for the datasource. - /// Gets or sets the data - /// deletion detection policy for the datasource. - public DataSource(string name, string type, DataSourceCredentials credentials, DataContainer container, string description = default(string), DataChangeDetectionPolicy dataChangeDetectionPolicy = default(DataChangeDetectionPolicy), DataDeletionDetectionPolicy dataDeletionDetectionPolicy = default(DataDeletionDetectionPolicy)) - { - Name = name; - Description = description; - Type = type; - Credentials = credentials; - Container = container; - DataChangeDetectionPolicy = dataChangeDetectionPolicy; - DataDeletionDetectionPolicy = dataDeletionDetectionPolicy; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the datasource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the description of the datasource. - /// - [JsonProperty(PropertyName = "description")] - public string Description { get; set; } - - /// - /// Gets or sets the type of the datasource. - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Gets or sets credentials for the datasource. - /// - [JsonProperty(PropertyName = "credentials")] - public DataSourceCredentials Credentials { get; set; } - - /// - /// Gets or sets the data container for the datasource. - /// - [JsonProperty(PropertyName = "container")] - public DataContainer Container { get; set; } - - /// - /// Gets or sets the data change detection policy for the datasource. - /// - [JsonProperty(PropertyName = "dataChangeDetectionPolicy")] - public DataChangeDetectionPolicy DataChangeDetectionPolicy { get; set; } - - /// - /// Gets or sets the data deletion detection policy for the datasource. - /// - [JsonProperty(PropertyName = "dataDeletionDetectionPolicy")] - public DataDeletionDetectionPolicy DataDeletionDetectionPolicy { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - if (Type == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Type"); - } - if (Credentials == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Credentials"); - } - if (Container == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Container"); - } - if (Credentials != null) - { - Credentials.Validate(); - } - if (Container != null) - { - Container.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/DataSourceCredentials.cs b/Samples/1c-multiple-input-swaggers/Client/Models/DataSourceCredentials.cs index 5d8c0e6a6..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/DataSourceCredentials.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/DataSourceCredentials.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Represents credentials that can be used to connect to a datasource. - /// - public partial class DataSourceCredentials - { - /// - /// Initializes a new instance of the DataSourceCredentials class. - /// - public DataSourceCredentials() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the DataSourceCredentials class. - /// - /// Gets or sets the connection string - /// for the datasource. - public DataSourceCredentials(string connectionString) - { - ConnectionString = connectionString; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the connection string for the datasource. - /// - [JsonProperty(PropertyName = "connectionString")] - public string ConnectionString { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (ConnectionString == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ConnectionString"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/Endpoints.cs b/Samples/1c-multiple-input-swaggers/Client/Models/Endpoints.cs index 067b0e85d..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/Endpoints.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/Endpoints.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/HighWaterMarkChangeDetectionPolicy.cs b/Samples/1c-multiple-input-swaggers/Client/Models/HighWaterMarkChangeDetectionPolicy.cs index bb92e7ea6..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/HighWaterMarkChangeDetectionPolicy.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/HighWaterMarkChangeDetectionPolicy.cs @@ -1,66 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines a data change detection policy that captures changes based on - /// the value of a high water mark column. - /// - [Newtonsoft.Json.JsonObject("#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy")] - public partial class HighWaterMarkChangeDetectionPolicy : DataChangeDetectionPolicy - { - /// - /// Initializes a new instance of the - /// HighWaterMarkChangeDetectionPolicy class. - /// - public HighWaterMarkChangeDetectionPolicy() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// HighWaterMarkChangeDetectionPolicy class. - /// - /// Gets or sets the name of the - /// high water mark column. - public HighWaterMarkChangeDetectionPolicy(string highWaterMarkColumnName) - { - HighWaterMarkColumnName = highWaterMarkColumnName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the high water mark column. - /// - [JsonProperty(PropertyName = "highWaterMarkColumnName")] - public string HighWaterMarkColumnName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (HighWaterMarkColumnName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "HighWaterMarkColumnName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/Index.cs b/Samples/1c-multiple-input-swaggers/Client/Models/Index.cs index 8a2725286..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/Index.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/Index.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Represents an index definition in Azure Search, which describes the - /// fields and search behavior of an index. - /// - public partial class Index - { - /// - /// Initializes a new instance of the Index class. - /// - public Index() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Index class. - /// - /// Gets or sets the name of the index. - /// Gets or sets the fields of the index. - /// Gets or sets the scoring profiles for - /// the index. - /// Gets or sets the name of the - /// scoring profile to use if none is specified in the query. If this - /// property is not set and no scoring profile is specified in the - /// query, then default scoring (tf-idf) will be used. - /// Gets or sets options to control - /// Cross-Origin Resource Sharing (CORS) for the index. - /// Gets or sets the suggesters for the - /// index. - public Index(string name, IList fields, IList scoringProfiles = default(IList), string defaultScoringProfile = default(string), CorsOptions corsOptions = default(CorsOptions), IList suggesters = default(IList)) - { - Name = name; - Fields = fields; - ScoringProfiles = scoringProfiles; - DefaultScoringProfile = defaultScoringProfile; - CorsOptions = corsOptions; - Suggesters = suggesters; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the index. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the fields of the index. - /// - [JsonProperty(PropertyName = "fields")] - public IList Fields { get; set; } - - /// - /// Gets or sets the scoring profiles for the index. - /// - [JsonProperty(PropertyName = "scoringProfiles")] - public IList ScoringProfiles { get; set; } - - /// - /// Gets or sets the name of the scoring profile to use if none is - /// specified in the query. If this property is not set and no scoring - /// profile is specified in the query, then default scoring (tf-idf) - /// will be used. - /// - [JsonProperty(PropertyName = "defaultScoringProfile")] - public string DefaultScoringProfile { get; set; } - - /// - /// Gets or sets options to control Cross-Origin Resource Sharing - /// (CORS) for the index. - /// - [JsonProperty(PropertyName = "corsOptions")] - public CorsOptions CorsOptions { get; set; } - - /// - /// Gets or sets the suggesters for the index. - /// - [JsonProperty(PropertyName = "suggesters")] - public IList Suggesters { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - if (Fields == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Fields"); - } - if (Fields != null) - { - foreach (var element in Fields) - { - if (element != null) - { - element.Validate(); - } - } - } - if (ScoringProfiles != null) - { - foreach (var element1 in ScoringProfiles) - { - if (element1 != null) - { - element1.Validate(); - } - } - } - if (CorsOptions != null) - { - CorsOptions.Validate(); - } - if (Suggesters != null) - { - foreach (var element2 in Suggesters) - { - if (element2 != null) - { - element2.Validate(); - } - } - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/Indexer.cs b/Samples/1c-multiple-input-swaggers/Client/Models/Indexer.cs index c8fc7af39..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/Indexer.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/Indexer.cs @@ -1,121 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Represents an Azure Search indexer. - /// - /// - public partial class Indexer - { - /// - /// Initializes a new instance of the Indexer class. - /// - public Indexer() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Indexer class. - /// - /// Gets or sets the name of the indexer. - /// Gets or sets the name of the - /// datasource from which this indexer reads data. - /// Gets or sets the name of the index to - /// which this indexer writes data. - /// Gets or sets the description of the - /// indexer. - /// Gets or sets the schedule for this - /// indexer. - /// Gets or sets parameters for indexer - /// execution. - public Indexer(string name, string dataSourceName, string targetIndexName, string description = default(string), IndexingSchedule schedule = default(IndexingSchedule), IndexingParameters parameters = default(IndexingParameters)) - { - Name = name; - Description = description; - DataSourceName = dataSourceName; - TargetIndexName = targetIndexName; - Schedule = schedule; - Parameters = parameters; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the indexer. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the description of the indexer. - /// - [JsonProperty(PropertyName = "description")] - public string Description { get; set; } - - /// - /// Gets or sets the name of the datasource from which this indexer - /// reads data. - /// - [JsonProperty(PropertyName = "dataSourceName")] - public string DataSourceName { get; set; } - - /// - /// Gets or sets the name of the index to which this indexer writes - /// data. - /// - [JsonProperty(PropertyName = "targetIndexName")] - public string TargetIndexName { get; set; } - - /// - /// Gets or sets the schedule for this indexer. - /// - [JsonProperty(PropertyName = "schedule")] - public IndexingSchedule Schedule { get; set; } - - /// - /// Gets or sets parameters for indexer execution. - /// - [JsonProperty(PropertyName = "parameters")] - public IndexingParameters Parameters { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - if (DataSourceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "DataSourceName"); - } - if (TargetIndexName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetIndexName"); - } - if (Schedule != null) - { - Schedule.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/IndexerExecutionStatus.cs b/Samples/1c-multiple-input-swaggers/Client/Models/IndexerExecutionStatus.cs index 4f49e5017..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/IndexerExecutionStatus.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/IndexerExecutionStatus.cs @@ -1,68 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for IndexerExecutionStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum IndexerExecutionStatus - { - [EnumMember(Value = "transientFailure")] - TransientFailure, - [EnumMember(Value = "success")] - Success, - [EnumMember(Value = "inProgress")] - InProgress, - [EnumMember(Value = "reset")] - Reset - } - internal static class IndexerExecutionStatusEnumExtension - { - internal static string ToSerializedValue(this IndexerExecutionStatus? value) - { - return value == null ? null : ((IndexerExecutionStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this IndexerExecutionStatus value) - { - switch( value ) - { - case IndexerExecutionStatus.TransientFailure: - return "transientFailure"; - case IndexerExecutionStatus.Success: - return "success"; - case IndexerExecutionStatus.InProgress: - return "inProgress"; - case IndexerExecutionStatus.Reset: - return "reset"; - } - return null; - } - - internal static IndexerExecutionStatus? ParseIndexerExecutionStatus(this string value) - { - switch( value ) - { - case "transientFailure": - return IndexerExecutionStatus.TransientFailure; - case "success": - return IndexerExecutionStatus.Success; - case "inProgress": - return IndexerExecutionStatus.InProgress; - case "reset": - return IndexerExecutionStatus.Reset; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/IndexerStatus.cs b/Samples/1c-multiple-input-swaggers/Client/Models/IndexerStatus.cs index f5b4c8e7c..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/IndexerStatus.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/IndexerStatus.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for IndexerStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum IndexerStatus - { - [EnumMember(Value = "unknown")] - Unknown, - [EnumMember(Value = "error")] - Error, - [EnumMember(Value = "running")] - Running - } - internal static class IndexerStatusEnumExtension - { - internal static string ToSerializedValue(this IndexerStatus? value) - { - return value == null ? null : ((IndexerStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this IndexerStatus value) - { - switch( value ) - { - case IndexerStatus.Unknown: - return "unknown"; - case IndexerStatus.Error: - return "error"; - case IndexerStatus.Running: - return "running"; - } - return null; - } - - internal static IndexerStatus? ParseIndexerStatus(this string value) - { - switch( value ) - { - case "unknown": - return IndexerStatus.Unknown; - case "error": - return IndexerStatus.Error; - case "running": - return IndexerStatus.Running; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/IndexingParameters.cs b/Samples/1c-multiple-input-swaggers/Client/Models/IndexingParameters.cs index 73e09d09b..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/IndexingParameters.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/IndexingParameters.cs @@ -1,78 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Represents parameters for indexer execution. - /// - public partial class IndexingParameters - { - /// - /// Initializes a new instance of the IndexingParameters class. - /// - public IndexingParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the IndexingParameters class. - /// - /// Gets or sets the maximum number of - /// items that can fail indexing for indexer execution to still be - /// considered successful. -1 means no limit. Default is 0. - /// Gets or sets the maximum - /// number of items in a single batch that can fail indexing for the - /// batch to still be considered successful. -1 means no limit. Default - /// is 0. - /// Gets or sets whether indexer will - /// base64-encode all values that are inserted into key field of the - /// target index. This is needed if keys can contain characters that - /// are invalid in keys (such as dot '.'). Default is false. - public IndexingParameters(int? maxFailedItems = default(int?), int? maxFailedItemsPerBatch = default(int?), bool? base64EncodeKeys = default(bool?)) - { - MaxFailedItems = maxFailedItems; - MaxFailedItemsPerBatch = maxFailedItemsPerBatch; - Base64EncodeKeys = base64EncodeKeys; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the maximum number of items that can fail indexing for - /// indexer execution to still be considered successful. -1 means no - /// limit. Default is 0. - /// - [JsonProperty(PropertyName = "maxFailedItems")] - public int? MaxFailedItems { get; set; } - - /// - /// Gets or sets the maximum number of items in a single batch that can - /// fail indexing for the batch to still be considered successful. -1 - /// means no limit. Default is 0. - /// - [JsonProperty(PropertyName = "maxFailedItemsPerBatch")] - public int? MaxFailedItemsPerBatch { get; set; } - - /// - /// Gets or sets whether indexer will base64-encode all values that are - /// inserted into key field of the target index. This is needed if keys - /// can contain characters that are invalid in keys (such as dot '.'). - /// Default is false. - /// - [JsonProperty(PropertyName = "base64EncodeKeys")] - public bool? Base64EncodeKeys { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/ItemError.cs b/Samples/1c-multiple-input-swaggers/Client/Models/ItemError.cs index 447fb772f..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/ItemError.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/ItemError.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Represents an item- or document-level indexing error. - /// - public partial class ItemError - { - /// - /// Initializes a new instance of the ItemError class. - /// - public ItemError() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ItemError class. - /// - /// Gets the key of the item for which indexing - /// failed. - /// Gets the message describing the error - /// that occurred while attempting to index the item. - public ItemError(string key = default(string), string errorMessage = default(string)) - { - Key = key; - ErrorMessage = errorMessage; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the key of the item for which indexing failed. - /// - [JsonProperty(PropertyName = "key")] - public string Key { get; private set; } - - /// - /// Gets the message describing the error that occurred while - /// attempting to index the item. - /// - [JsonProperty(PropertyName = "errorMessage")] - public string ErrorMessage { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/ProvisioningState.cs b/Samples/1c-multiple-input-swaggers/Client/Models/ProvisioningState.cs index 155026d25..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/ProvisioningState.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/ProvisioningState.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/Reason.cs b/Samples/1c-multiple-input-swaggers/Client/Models/Reason.cs index 63683c365..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/Reason.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/Reason.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/Resource.cs b/Samples/1c-multiple-input-swaggers/Client/Models/Resource.cs index 97ed11b2f..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/Resource.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/Resource.cs @@ -1,78 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionAggregation.cs b/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionAggregation.cs index 8e94fc249..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionAggregation.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionAggregation.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ScoringFunctionAggregation. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ScoringFunctionAggregation - { - [EnumMember(Value = "sum")] - Sum, - [EnumMember(Value = "average")] - Average, - [EnumMember(Value = "minimum")] - Minimum, - [EnumMember(Value = "maximum")] - Maximum, - [EnumMember(Value = "firstMatching")] - FirstMatching - } - internal static class ScoringFunctionAggregationEnumExtension - { - internal static string ToSerializedValue(this ScoringFunctionAggregation? value) - { - return value == null ? null : ((ScoringFunctionAggregation)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ScoringFunctionAggregation value) - { - switch( value ) - { - case ScoringFunctionAggregation.Sum: - return "sum"; - case ScoringFunctionAggregation.Average: - return "average"; - case ScoringFunctionAggregation.Minimum: - return "minimum"; - case ScoringFunctionAggregation.Maximum: - return "maximum"; - case ScoringFunctionAggregation.FirstMatching: - return "firstMatching"; - } - return null; - } - - internal static ScoringFunctionAggregation? ParseScoringFunctionAggregation(this string value) - { - switch( value ) - { - case "sum": - return ScoringFunctionAggregation.Sum; - case "average": - return ScoringFunctionAggregation.Average; - case "minimum": - return ScoringFunctionAggregation.Minimum; - case "maximum": - return ScoringFunctionAggregation.Maximum; - case "firstMatching": - return ScoringFunctionAggregation.FirstMatching; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionInterpolation.cs b/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionInterpolation.cs index 47fda3532..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionInterpolation.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/ScoringFunctionInterpolation.cs @@ -1,68 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ScoringFunctionInterpolation. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ScoringFunctionInterpolation - { - [EnumMember(Value = "linear")] - Linear, - [EnumMember(Value = "constant")] - Constant, - [EnumMember(Value = "quadratic")] - Quadratic, - [EnumMember(Value = "logarithmic")] - Logarithmic - } - internal static class ScoringFunctionInterpolationEnumExtension - { - internal static string ToSerializedValue(this ScoringFunctionInterpolation? value) - { - return value == null ? null : ((ScoringFunctionInterpolation)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ScoringFunctionInterpolation value) - { - switch( value ) - { - case ScoringFunctionInterpolation.Linear: - return "linear"; - case ScoringFunctionInterpolation.Constant: - return "constant"; - case ScoringFunctionInterpolation.Quadratic: - return "quadratic"; - case ScoringFunctionInterpolation.Logarithmic: - return "logarithmic"; - } - return null; - } - - internal static ScoringFunctionInterpolation? ParseScoringFunctionInterpolation(this string value) - { - switch( value ) - { - case "linear": - return ScoringFunctionInterpolation.Linear; - case "constant": - return ScoringFunctionInterpolation.Constant; - case "quadratic": - return ScoringFunctionInterpolation.Quadratic; - case "logarithmic": - return ScoringFunctionInterpolation.Logarithmic; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/SearchRequestOptions.cs b/Samples/1c-multiple-input-swaggers/Client/Models/SearchRequestOptions.cs index fb7748b4c..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/SearchRequestOptions.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/SearchRequestOptions.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Additional parameters for a set of operations. - /// - public partial class SearchRequestOptions - { - /// - /// Initializes a new instance of the SearchRequestOptions class. - /// - public SearchRequestOptions() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SearchRequestOptions class. - /// - /// Tracking ID sent with the request to - /// help with debugging. - public SearchRequestOptions(System.Guid? clientRequestId = default(System.Guid?)) - { - ClientRequestId = clientRequestId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets tracking ID sent with the request to help with - /// debugging. - /// - [JsonProperty(PropertyName = "")] - public System.Guid? ClientRequestId { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/SoftDeleteColumnDeletionDetectionPolicy.cs b/Samples/1c-multiple-input-swaggers/Client/Models/SoftDeleteColumnDeletionDetectionPolicy.cs index 5bb14a647..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/SoftDeleteColumnDeletionDetectionPolicy.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/SoftDeleteColumnDeletionDetectionPolicy.cs @@ -1,63 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines a data deletion detection policy that implements a - /// soft-deletion strategy. It determines whether an item should be deleted - /// based on the value of a designated 'soft delete' column. - /// - [Newtonsoft.Json.JsonObject("#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy")] - public partial class SoftDeleteColumnDeletionDetectionPolicy : DataDeletionDetectionPolicy - { - /// - /// Initializes a new instance of the - /// SoftDeleteColumnDeletionDetectionPolicy class. - /// - public SoftDeleteColumnDeletionDetectionPolicy() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// SoftDeleteColumnDeletionDetectionPolicy class. - /// - /// Gets or sets the name of the - /// column to use for soft-deletion detection. - /// Gets or sets the marker value - /// that indentifies an item as deleted. - public SoftDeleteColumnDeletionDetectionPolicy(string softDeleteColumnName = default(string), string softDeleteMarkerValue = default(string)) - { - SoftDeleteColumnName = softDeleteColumnName; - SoftDeleteMarkerValue = softDeleteMarkerValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the column to use for soft-deletion - /// detection. - /// - [JsonProperty(PropertyName = "softDeleteColumnName")] - public string SoftDeleteColumnName { get; set; } - - /// - /// Gets or sets the marker value that indentifies an item as deleted. - /// - [JsonProperty(PropertyName = "softDeleteMarkerValue")] - public string SoftDeleteMarkerValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/SqlIntegratedChangeTrackingPolicy.cs b/Samples/1c-multiple-input-swaggers/Client/Models/SqlIntegratedChangeTrackingPolicy.cs index de9c96b91..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/SqlIntegratedChangeTrackingPolicy.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/SqlIntegratedChangeTrackingPolicy.cs @@ -1,35 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines a data change detection policy that captures changes using the - /// Integrated Change Tracking feature of Azure SQL Database. - /// - [Newtonsoft.Json.JsonObject("#Microsoft.Azure.Search.SqlIntegratedChangeTrackingPolicy")] - public partial class SqlIntegratedChangeTrackingPolicy : DataChangeDetectionPolicy - { - /// - /// Initializes a new instance of the SqlIntegratedChangeTrackingPolicy - /// class. - /// - public SqlIntegratedChangeTrackingPolicy() - { - CustomInit(); - } - - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccount.cs b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccount.cs index c5b1dda63..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccount.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccount.cs @@ -1,198 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs index dc6091d05..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCreateParameters.cs b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCreateParameters.cs index 84d73f41b..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCreateParameters.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountCreateParameters.cs @@ -1,87 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountKeys.cs b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountKeys.cs index 7fc566ab1..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountKeys.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountKeys.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountListResult.cs b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountListResult.cs index 34ef0d407..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountListResult.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountListResult.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The list storage accounts operation response. - /// - public partial class StorageAccountListResult - { - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - public StorageAccountListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - /// Gets the list of storage accounts and their - /// properties. - public StorageAccountListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of storage accounts and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountRegenerateKeyParameters.cs index f361ec93d..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountUpdateParameters.cs b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountUpdateParameters.cs index de7eaf638..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountUpdateParameters.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/StorageAccountUpdateParameters.cs @@ -1,99 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/SuggesterSearchMode.cs b/Samples/1c-multiple-input-swaggers/Client/Models/SuggesterSearchMode.cs index 00e17bc7a..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/SuggesterSearchMode.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/SuggesterSearchMode.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for SuggesterSearchMode. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum SuggesterSearchMode - { - [EnumMember(Value = "analyzingInfixMatching")] - AnalyzingInfixMatching - } - internal static class SuggesterSearchModeEnumExtension - { - internal static string ToSerializedValue(this SuggesterSearchMode? value) - { - return value == null ? null : ((SuggesterSearchMode)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this SuggesterSearchMode value) - { - switch( value ) - { - case SuggesterSearchMode.AnalyzingInfixMatching: - return "analyzingInfixMatching"; - } - return null; - } - - internal static SuggesterSearchMode? ParseSuggesterSearchMode(this string value) - { - switch( value ) - { - case "analyzingInfixMatching": - return SuggesterSearchMode.AnalyzingInfixMatching; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/TagScoringParameters.cs b/Samples/1c-multiple-input-swaggers/Client/Models/TagScoringParameters.cs index fbddc395d..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/TagScoringParameters.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/TagScoringParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Provides parameter values to a tag scoring function. - /// - public partial class TagScoringParameters - { - /// - /// Initializes a new instance of the TagScoringParameters class. - /// - public TagScoringParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TagScoringParameters class. - /// - /// Gets or sets the name of the parameter - /// passed in search queries to specify the list of tags to compare - /// against the target field. - public TagScoringParameters(string tagsParameter) - { - TagsParameter = tagsParameter; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the parameter passed in search queries to - /// specify the list of tags to compare against the target field. - /// - [JsonProperty(PropertyName = "tagsParameter")] - public string TagsParameter { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TagsParameter == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TagsParameter"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/Usage.cs b/Samples/1c-multiple-input-swaggers/Client/Models/Usage.cs index b2cb64807..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/Usage.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/Usage.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes Storage Resource Usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/UsageListResult.cs b/Samples/1c-multiple-input-swaggers/Client/Models/UsageListResult.cs index d8703370f..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/UsageListResult.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/UsageListResult.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List Usages operation response. - /// - public partial class UsageListResult - { - /// - /// Initializes a new instance of the UsageListResult class. - /// - public UsageListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageListResult class. - /// - /// Gets or sets the list Storage Resource - /// Usages. - public UsageListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the list Storage Resource Usages. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/UsageName.cs b/Samples/1c-multiple-input-swaggers/Client/Models/UsageName.cs index bb0428b48..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/UsageName.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/UsageName.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/Models/UsageUnit.cs b/Samples/1c-multiple-input-swaggers/Client/Models/UsageUnit.cs index 603dc0b3c..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/Models/UsageUnit.cs +++ b/Samples/1c-multiple-input-swaggers/Client/Models/UsageUnit.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/SearchandStorage.cs b/Samples/1c-multiple-input-swaggers/Client/SearchandStorage.cs index 3d1e67bae..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/SearchandStorage.cs +++ b/Samples/1c-multiple-input-swaggers/Client/SearchandStorage.cs @@ -1,188 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - public partial class SearchandStorage : ServiceClient, ISearchandStorage - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Gets the IDataSources. - /// - public virtual IDataSources DataSources { get; private set; } - - /// - /// Gets the IIndexers. - /// - public virtual IIndexers Indexers { get; private set; } - - /// - /// Gets the IIndexes. - /// - public virtual IIndexes Indexes { get; private set; } - - /// - /// Gets the IStorageAccounts. - /// - public virtual IStorageAccounts StorageAccounts { get; private set; } - - /// - /// Gets the IUsageOperations. - /// - public virtual IUsageOperations Usage { get; private set; } - - /// - /// Initializes a new instance of the SearchandStorage class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SearchandStorage(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SearchandStorage class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SearchandStorage(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SearchandStorage class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SearchandStorage(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SearchandStorage class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SearchandStorage(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - DataSources = new DataSources(this); - Indexers = new Indexers(this); - Indexes = new Indexes(this); - StorageAccounts = new StorageAccounts(this); - Usage = new UsageOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("@odata.type")); - DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("@odata.type")); - SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("@odata.type")); - DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("@odata.type")); - SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("type")); - DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("type")); - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/StorageAccounts.cs b/Samples/1c-multiple-input-swaggers/Client/StorageAccounts.cs index fb3957042..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/StorageAccounts.cs +++ b/Samples/1c-multiple-input-swaggers/Client/StorageAccounts.cs @@ -1,1591 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial class StorageAccounts : IServiceOperations, IStorageAccounts - { - /// - /// Initializes a new instance of the StorageAccounts class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageAccounts(SearchandStorage client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SearchandStorage - /// - public SearchandStorage Client { get; private set; } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - accountName.Validate(); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperties", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (regenerateKey == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "regenerateKey"); - } - if (regenerateKey != null) - { - regenerateKey.Validate(); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/StorageAccountsExtensions.cs b/Samples/1c-multiple-input-swaggers/Client/StorageAccountsExtensions.cs index 9ca28435c..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/StorageAccountsExtensions.cs +++ b/Samples/1c-multiple-input-swaggers/Client/StorageAccountsExtensions.cs @@ -1,438 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccounts. - /// - public static partial class StorageAccountsExtensions - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName) - { - return operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult(); - } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount Create(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static void Delete(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static StorageAccount GetProperties(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.GetPropertiesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertiesAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - public static StorageAccount Update(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - public static StorageAccountKeys ListKeys(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - public static StorageAccountListResult List(this IStorageAccounts operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IStorageAccounts operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - public static StorageAccountListResult ListByResourceGroup(this IStorageAccounts operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task ListByResourceGroupAsync(this IStorageAccounts operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - public static StorageAccountKeys RegenerateKey(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey) - { - return operations.RegenerateKeyAsync(resourceGroupName, accountName, regenerateKey).GetAwaiter().GetResult(); - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, regenerateKey, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/UsageOperations.cs b/Samples/1c-multiple-input-swaggers/Client/UsageOperations.cs index d1816656a..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/UsageOperations.cs +++ b/Samples/1c-multiple-input-swaggers/Client/UsageOperations.cs @@ -1,192 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial class UsageOperations : IServiceOperations, IUsageOperations - { - /// - /// Initializes a new instance of the UsageOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public UsageOperations(SearchandStorage client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SearchandStorage - /// - public SearchandStorage Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2015-06-15"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1c-multiple-input-swaggers/Client/UsageOperationsExtensions.cs b/Samples/1c-multiple-input-swaggers/Client/UsageOperationsExtensions.cs index 8a4e32995..9d6cafc2c 100644 --- a/Samples/1c-multiple-input-swaggers/Client/UsageOperationsExtensions.cs +++ b/Samples/1c-multiple-input-swaggers/Client/UsageOperationsExtensions.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Searchservice -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsageOperations. - /// - public static partial class UsageOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - public static UsageListResult List(this IUsageOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IUsageOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/IStorageAccountsOperations.cs b/Samples/1d-common-settings/base/folder/AzureClient/IStorageAccountsOperations.cs index 347b424d3..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/IStorageAccountsOperations.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/IStorageAccountsOperations.cs @@ -1,342 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccountsOperations operations. - /// - public partial interface IStorageAccountsOperations - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(string name, string type = "Microsoft.Storage/storageAccounts", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Resource location - /// - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - /// - /// Resource tags - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, string location, AccountType accountType, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Resource tags - /// - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - /// - /// User domain assigned to the storage account. Name is the CNAME - /// source. Only one custom domain is supported per storage account at - /// this time. To clear the existing custom domain, use an empty string - /// for the custom domain name property. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Resource location - /// - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - /// - /// Resource tags - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, string location, AccountType accountType, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/IStorageManagementClient.cs b/Samples/1d-common-settings/base/folder/AzureClient/IStorageManagementClient.cs index 77c3c9b25..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/IStorageManagementClient.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/IStorageManagementClient.cs @@ -1,84 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - - /// - /// The Storage Management Client. - /// - public partial interface IStorageManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - string ApiVersion { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// Gets the IStorageAccountsOperations. - /// - IStorageAccountsOperations StorageAccounts { get; } - - /// - /// Gets the IUsageOperations. - /// - IUsageOperations Usage { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/IUsageOperations.cs b/Samples/1d-common-settings/base/folder/AzureClient/IUsageOperations.cs index 75d706c25..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/IUsageOperations.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/IUsageOperations.cs @@ -1,47 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial interface IUsageOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountStatus.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountStatus.cs index a378133ae..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountStatus.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountStatus.cs @@ -1,60 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountType.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountType.cs index 64aab644e..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountType.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/AccountType.cs @@ -1,78 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/CheckNameAvailabilityResult.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/CheckNameAvailabilityResult.cs index eec1d5a65..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/CheckNameAvailabilityResult.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/CheckNameAvailabilityResult.cs @@ -1,80 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/CustomDomain.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/CustomDomain.cs index 51c7f3066..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/CustomDomain.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/CustomDomain.cs @@ -1,64 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/Endpoints.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/Endpoints.cs index ca86fd40e..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/Endpoints.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/Endpoints.cs @@ -1,76 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/Page.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/Page.cs index 926812652..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/Page.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/Page.cs @@ -1,53 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - - /// - /// Defines a page in Azure responses. - /// - /// Type of the page content items - [JsonObject] - public class Page : IPage - { - /// - /// Gets the link to the next page. - /// - [JsonProperty("")] - public string NextPageLink { get; private set; } - - [JsonProperty("value")] - private IList Items{ get; set; } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/ProvisioningState.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/ProvisioningState.cs index 2a6f6a967..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/ProvisioningState.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/ProvisioningState.cs @@ -1,66 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/Reason.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/Reason.cs index c5b45ba49..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/Reason.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/Reason.cs @@ -1,60 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/Resource.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/Resource.cs index 488bb2c29..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/Resource.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/Resource.cs @@ -1,84 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource : IResource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccount.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccount.cs index f5deb4a31..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccount.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccount.cs @@ -1,189 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCheckNameAvailabilityParameters.cs index 4c2ed6512..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,54 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCreateParameters.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCreateParameters.cs index 6b7af0025..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCreateParameters.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountCreateParameters.cs @@ -1,79 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountKeys.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountKeys.cs index c1b4087db..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountKeys.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountKeys.cs @@ -1,59 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountRegenerateKeyParameters.cs index edf4f41a7..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,48 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountUpdateParameters.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountUpdateParameters.cs index 52ffb59d2..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountUpdateParameters.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/StorageAccountUpdateParameters.cs @@ -1,91 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/Usage.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/Usage.cs index a01c5cc88..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/Usage.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/Usage.cs @@ -1,82 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes Storage Resource Usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageName.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageName.cs index 528c5699d..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageName.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageName.cs @@ -1,61 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageUnit.cs b/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageUnit.cs index 816ac3301..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageUnit.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/Models/UsageUnit.cs @@ -1,84 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperations.cs b/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperations.cs index da325aabb..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperations.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperations.cs @@ -1,1917 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccountsOperations operations. - /// - internal partial class StorageAccountsOperations : IServiceOperations, IStorageAccountsOperations - { - /// - /// Initializes a new instance of the StorageAccountsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal StorageAccountsOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(string name, string type = "Microsoft.Storage/storageAccounts", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - if (name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "name"); - } - StorageAccountCheckNameAvailabilityParameters accountName = new StorageAccountCheckNameAvailabilityParameters(); - if (name != null || type != null) - { - accountName.Name = name; - accountName.Type = type; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Resource location - /// - /// - /// Gets or sets the account type. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - /// - /// Resource tags - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, string location, AccountType accountType, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, location, accountType, tags, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperties", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Resource tags - /// - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other account types - /// cannot be changed to StandardZRS or PremiumLRS. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - /// - /// User domain assigned to the storage account. Name is the CNAME source. Only - /// one custom domain is supported per storage account at this time. To clear - /// the existing custom domain, use an empty string for the custom domain name - /// property. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - StorageAccountUpdateParameters parameters = new StorageAccountUpdateParameters(); - if (tags != null || accountType != null || customDomain != null) - { - parameters.Tags = tags; - parameters.AccountType = accountType; - parameters.CustomDomain = customDomain; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - if (keyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "keyName"); - } - StorageAccountRegenerateKeyParameters regenerateKey = new StorageAccountRegenerateKeyParameters(); - if (keyName != null) - { - regenerateKey.KeyName = keyName; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Resource location - /// - /// - /// Gets or sets the account type. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - /// - /// Resource tags - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, string location, AccountType accountType, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - if (location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "location"); - } - StorageAccountCreateParameters parameters = new StorageAccountCreateParameters(); - if (location != null || tags != null) - { - parameters.Location = location; - parameters.Tags = tags; - parameters.AccountType = accountType; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperationsExtensions.cs b/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperationsExtensions.cs index 3460e9d96..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperationsExtensions.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/StorageAccountsOperationsExtensions.cs @@ -1,317 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccountsOperations. - /// - public static partial class StorageAccountsOperationsExtensions - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this IStorageAccountsOperations operations, string name, string type = "Microsoft.Storage/storageAccounts", CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(name, type, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Resource location - /// - /// - /// Gets or sets the account type. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - /// - /// Resource tags - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, string location, AccountType accountType, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, location, accountType, tags, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertiesAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Resource tags - /// - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other account types - /// cannot be changed to StandardZRS or PremiumLRS. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - /// - /// User domain assigned to the storage account. Name is the CNAME source. Only - /// one custom domain is supported per storage account at this time. To clear - /// the existing custom domain, use an empty string for the custom domain name - /// property. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, tags, accountType, customDomain, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IStorageAccountsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByResourceGroupAsync(this IStorageAccountsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, string keyName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, keyName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Resource location - /// - /// - /// Gets or sets the account type. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - /// - /// Resource tags - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, string location, AccountType accountType, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, location, accountType, tags, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/StorageManagementClient.cs b/Samples/1d-common-settings/base/folder/AzureClient/StorageManagementClient.cs index f3b531527..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/StorageManagementClient.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/StorageManagementClient.cs @@ -1,327 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - - /// - /// The Storage Management Client. - /// - public partial class StorageManagementClient : ServiceClient, IStorageManagementClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - public string ApiVersion { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Gets the IStorageAccountsOperations. - /// - public virtual IStorageAccountsOperations StorageAccounts { get; private set; } - - /// - /// Gets the IUsageOperations. - /// - public virtual IUsageOperations Usage { get; private set; } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - StorageAccounts = new StorageAccountsOperations(this); - Usage = new UsageOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2015-06-15"; - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/UsageOperations.cs b/Samples/1d-common-settings/base/folder/AzureClient/UsageOperations.cs index 2b1734b85..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/UsageOperations.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/UsageOperations.cs @@ -1,233 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - internal partial class UsageOperations : IServiceOperations, IUsageOperations - { - /// - /// Initializes a new instance of the UsageOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal UsageOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/AzureClient/UsageOperationsExtensions.cs b/Samples/1d-common-settings/base/folder/AzureClient/UsageOperationsExtensions.cs index aa4bf14ec..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/AzureClient/UsageOperationsExtensions.cs +++ b/Samples/1d-common-settings/base/folder/AzureClient/UsageOperationsExtensions.cs @@ -1,45 +1 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsageOperations. - /// - public static partial class UsageOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IUsageOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/IStorageAccounts.cs b/Samples/1d-common-settings/base/folder/Client/IStorageAccounts.cs index 26346e3aa..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/IStorageAccounts.cs +++ b/Samples/1d-common-settings/base/folder/Client/IStorageAccounts.cs @@ -1,279 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial interface IStorageAccounts - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one - /// property can be changed at a time using this API. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 - /// for the default keys - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/IStorageManagementClient.cs b/Samples/1d-common-settings/base/folder/Client/IStorageManagementClient.cs index c253e891b..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/IStorageManagementClient.cs +++ b/Samples/1d-common-settings/base/folder/Client/IStorageManagementClient.cs @@ -1,57 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Models; - using Newtonsoft.Json; - - /// - /// The Storage Management Client. - /// - public partial interface IStorageManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - string ApiVersion { get; set; } - - - /// - /// Gets the IStorageAccounts. - /// - IStorageAccounts StorageAccounts { get; } - - /// - /// Gets the IUsageOperations. - /// - IUsageOperations Usage { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/IUsageOperations.cs b/Samples/1d-common-settings/base/folder/Client/IUsageOperations.cs index 44a02c43f..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/IUsageOperations.cs +++ b/Samples/1d-common-settings/base/folder/Client/IUsageOperations.cs @@ -1,43 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial interface IUsageOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/AccountStatus.cs b/Samples/1d-common-settings/base/folder/Client/Models/AccountStatus.cs index 8e7637544..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/AccountStatus.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/AccountStatus.cs @@ -1,57 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/AccountType.cs b/Samples/1d-common-settings/base/folder/Client/Models/AccountType.cs index 184384adf..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/AccountType.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/AccountType.cs @@ -1,75 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/CheckNameAvailabilityResult.cs b/Samples/1d-common-settings/base/folder/Client/Models/CheckNameAvailabilityResult.cs index edfc5d3f8..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/CheckNameAvailabilityResult.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/CheckNameAvailabilityResult.cs @@ -1,77 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/CustomDomain.cs b/Samples/1d-common-settings/base/folder/Client/Models/CustomDomain.cs index 6544ef273..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/CustomDomain.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/CustomDomain.cs @@ -1,75 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/Endpoints.cs b/Samples/1d-common-settings/base/folder/Client/Models/Endpoints.cs index 5f8cfb82e..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/Endpoints.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/Endpoints.cs @@ -1,73 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/ProvisioningState.cs b/Samples/1d-common-settings/base/folder/Client/Models/ProvisioningState.cs index f7ca7a9af..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/ProvisioningState.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/ProvisioningState.cs @@ -1,63 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/Reason.cs b/Samples/1d-common-settings/base/folder/Client/Models/Reason.cs index f16dcb751..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/Reason.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/Reason.cs @@ -1,57 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/Resource.cs b/Samples/1d-common-settings/base/folder/Client/Models/Resource.cs index f17922333..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/Resource.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/Resource.cs @@ -1,79 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccount.cs b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccount.cs index 1e9533a52..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccount.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccount.cs @@ -1,199 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs index d5b4b040f..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,65 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCreateParameters.cs b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCreateParameters.cs index 1e39f28a7..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCreateParameters.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountCreateParameters.cs @@ -1,88 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountKeys.cs b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountKeys.cs index f71769008..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountKeys.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountKeys.cs @@ -1,56 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountListResult.cs b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountListResult.cs index b29b90571..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountListResult.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountListResult.cs @@ -1,51 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The list storage accounts operation response. - /// - public partial class StorageAccountListResult - { - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - public StorageAccountListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - /// Gets the list of storage accounts and their - /// properties. - public StorageAccountListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of storage accounts and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountRegenerateKeyParameters.cs index 1366dd35c..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,59 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountUpdateParameters.cs b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountUpdateParameters.cs index f3b51e95a..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountUpdateParameters.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/StorageAccountUpdateParameters.cs @@ -1,100 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/Usage.cs b/Samples/1d-common-settings/base/folder/Client/Models/Usage.cs index a784ff268..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/Usage.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/Usage.cs @@ -1,93 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes Storage Resource Usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/UsageListResult.cs b/Samples/1d-common-settings/base/folder/Client/Models/UsageListResult.cs index a72f6648d..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/UsageListResult.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/UsageListResult.cs @@ -1,51 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List Usages operation response. - /// - public partial class UsageListResult - { - /// - /// Initializes a new instance of the UsageListResult class. - /// - public UsageListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageListResult class. - /// - /// Gets or sets the list Storage Resource - /// Usages. - public UsageListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the list Storage Resource Usages. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/UsageName.cs b/Samples/1d-common-settings/base/folder/Client/Models/UsageName.cs index 2abc382ab..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/UsageName.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/UsageName.cs @@ -1,58 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/Models/UsageUnit.cs b/Samples/1d-common-settings/base/folder/Client/Models/UsageUnit.cs index bfe36d1ad..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/Models/UsageUnit.cs +++ b/Samples/1d-common-settings/base/folder/Client/Models/UsageUnit.cs @@ -1,81 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/StorageAccounts.cs b/Samples/1d-common-settings/base/folder/Client/StorageAccounts.cs index dfb3db9ca..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/StorageAccounts.cs +++ b/Samples/1d-common-settings/base/folder/Client/StorageAccounts.cs @@ -1,1610 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial class StorageAccounts : IServiceOperations, IStorageAccounts - { - /// - /// Initializes a new instance of the StorageAccounts class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageAccounts(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - accountName.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperties", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (regenerateKey == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "regenerateKey"); - } - if (regenerateKey != null) - { - regenerateKey.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/StorageAccountsExtensions.cs b/Samples/1d-common-settings/base/folder/Client/StorageAccountsExtensions.cs index 4ab01c7bd..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/StorageAccountsExtensions.cs +++ b/Samples/1d-common-settings/base/folder/Client/StorageAccountsExtensions.cs @@ -1,439 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccounts. - /// - public static partial class StorageAccountsExtensions - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName) - { - return operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult(); - } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount Create(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static void Delete(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static StorageAccount GetProperties(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.GetPropertiesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertiesAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - public static StorageAccount Update(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - public static StorageAccountKeys ListKeys(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - public static StorageAccountListResult List(this IStorageAccounts operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IStorageAccounts operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - public static StorageAccountListResult ListByResourceGroup(this IStorageAccounts operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task ListByResourceGroupAsync(this IStorageAccounts operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - public static StorageAccountKeys RegenerateKey(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey) - { - return operations.RegenerateKeyAsync(resourceGroupName, accountName, regenerateKey).GetAwaiter().GetResult(); - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, regenerateKey, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/StorageManagementClient.cs b/Samples/1d-common-settings/base/folder/Client/StorageManagementClient.cs index 1e0b6d657..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/StorageManagementClient.cs +++ b/Samples/1d-common-settings/base/folder/Client/StorageManagementClient.cs @@ -1,173 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// The Storage Management Client. - /// - public partial class StorageManagementClient : ServiceClient, IStorageManagementClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - public string ApiVersion { get; set; } - - /// - /// Gets the IStorageAccounts. - /// - public virtual IStorageAccounts StorageAccounts { get; private set; } - - /// - /// Gets the IUsageOperations. - /// - public virtual IUsageOperations Usage { get; private set; } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public StorageManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public StorageManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - StorageAccounts = new StorageAccounts(this); - Usage = new UsageOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/UsageOperations.cs b/Samples/1d-common-settings/base/folder/Client/UsageOperations.cs index a7ffb95e1..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/UsageOperations.cs +++ b/Samples/1d-common-settings/base/folder/Client/UsageOperations.cs @@ -1,195 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial class UsageOperations : IServiceOperations, IUsageOperations - { - /// - /// Initializes a new instance of the UsageOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public UsageOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/1d-common-settings/base/folder/Client/UsageOperationsExtensions.cs b/Samples/1d-common-settings/base/folder/Client/UsageOperationsExtensions.cs index 252b82eea..9d6cafc2c 100644 --- a/Samples/1d-common-settings/base/folder/Client/UsageOperationsExtensions.cs +++ b/Samples/1d-common-settings/base/folder/Client/UsageOperationsExtensions.cs @@ -1,50 +1 @@ -// -// This is my custom license header. I am a nice person so please don't steal -// my code. -// -// Cheers. -// - -namespace AwesomeNamespace -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsageOperations. - /// - public static partial class UsageOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - public static UsageListResult List(this IUsageOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IUsageOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/IStorageAccountsOperations.cs b/Samples/2a-validation/CSharp/IStorageAccountsOperations.cs index 77dde94c9..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/IStorageAccountsOperations.cs +++ b/Samples/2a-validation/CSharp/IStorageAccountsOperations.cs @@ -1,313 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccountsOperations operations. - /// - public partial interface IStorageAccountsOperations - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one - /// property can be changed at a time using this API. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 - /// for the default keys - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/IStorageManagementClient.cs b/Samples/2a-validation/CSharp/IStorageManagementClient.cs index d8502441d..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/IStorageManagementClient.cs +++ b/Samples/2a-validation/CSharp/IStorageManagementClient.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - - /// - /// The Storage Management Client. - /// - public partial interface IStorageManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - string ApiVersion { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// Gets the IStorageAccountsOperations. - /// - IStorageAccountsOperations StorageAccounts { get; } - - /// - /// Gets the IUsageOperations. - /// - IUsageOperations Usage { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/IUsageOperations.cs b/Samples/2a-validation/CSharp/IUsageOperations.cs index 58a08df97..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/IUsageOperations.cs +++ b/Samples/2a-validation/CSharp/IUsageOperations.cs @@ -1,43 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial interface IUsageOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/AccountStatus.cs b/Samples/2a-validation/CSharp/Models/AccountStatus.cs index add75dbff..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/AccountStatus.cs +++ b/Samples/2a-validation/CSharp/Models/AccountStatus.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/AccountType.cs b/Samples/2a-validation/CSharp/Models/AccountType.cs index 927636470..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/AccountType.cs +++ b/Samples/2a-validation/CSharp/Models/AccountType.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/CheckNameAvailabilityResult.cs b/Samples/2a-validation/CSharp/Models/CheckNameAvailabilityResult.cs index 3cd5b4328..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/CheckNameAvailabilityResult.cs +++ b/Samples/2a-validation/CSharp/Models/CheckNameAvailabilityResult.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/CustomDomain.cs b/Samples/2a-validation/CSharp/Models/CustomDomain.cs index 7e45930f6..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/CustomDomain.cs +++ b/Samples/2a-validation/CSharp/Models/CustomDomain.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/Endpoints.cs b/Samples/2a-validation/CSharp/Models/Endpoints.cs index cde486b00..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/Endpoints.cs +++ b/Samples/2a-validation/CSharp/Models/Endpoints.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/Page.cs b/Samples/2a-validation/CSharp/Models/Page.cs index f0225b4df..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/Page.cs +++ b/Samples/2a-validation/CSharp/Models/Page.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - - /// - /// Defines a page in Azure responses. - /// - /// Type of the page content items - [JsonObject] - public class Page : IPage - { - /// - /// Gets the link to the next page. - /// - [JsonProperty("")] - public string NextPageLink { get; private set; } - - [JsonProperty("value")] - private IList Items{ get; set; } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/ProvisioningState.cs b/Samples/2a-validation/CSharp/Models/ProvisioningState.cs index b5b85bac3..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/ProvisioningState.cs +++ b/Samples/2a-validation/CSharp/Models/ProvisioningState.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/Reason.cs b/Samples/2a-validation/CSharp/Models/Reason.cs index ecaf08ffd..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/Reason.cs +++ b/Samples/2a-validation/CSharp/Models/Reason.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/Resource.cs b/Samples/2a-validation/CSharp/Models/Resource.cs index eef720b30..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/Resource.cs +++ b/Samples/2a-validation/CSharp/Models/Resource.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource : IResource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/StorageAccount.cs b/Samples/2a-validation/CSharp/Models/StorageAccount.cs index ab7cb2a5a..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/StorageAccount.cs +++ b/Samples/2a-validation/CSharp/Models/StorageAccount.cs @@ -1,198 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/2a-validation/CSharp/Models/StorageAccountCheckNameAvailabilityParameters.cs index 4c0b6121c..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/2a-validation/CSharp/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/StorageAccountCreateParameters.cs b/Samples/2a-validation/CSharp/Models/StorageAccountCreateParameters.cs index 261f57172..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/StorageAccountCreateParameters.cs +++ b/Samples/2a-validation/CSharp/Models/StorageAccountCreateParameters.cs @@ -1,88 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/StorageAccountKeys.cs b/Samples/2a-validation/CSharp/Models/StorageAccountKeys.cs index 44c01154f..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/StorageAccountKeys.cs +++ b/Samples/2a-validation/CSharp/Models/StorageAccountKeys.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/2a-validation/CSharp/Models/StorageAccountRegenerateKeyParameters.cs index 8f04bcd7a..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/2a-validation/CSharp/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/StorageAccountUpdateParameters.cs b/Samples/2a-validation/CSharp/Models/StorageAccountUpdateParameters.cs index 937b4acc9..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/StorageAccountUpdateParameters.cs +++ b/Samples/2a-validation/CSharp/Models/StorageAccountUpdateParameters.cs @@ -1,100 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/Usage.cs b/Samples/2a-validation/CSharp/Models/Usage.cs index cc75396a7..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/Usage.cs +++ b/Samples/2a-validation/CSharp/Models/Usage.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes Storage Resource Usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/UsageName.cs b/Samples/2a-validation/CSharp/Models/UsageName.cs index 8fa9f973f..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/UsageName.cs +++ b/Samples/2a-validation/CSharp/Models/UsageName.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/Models/UsageUnit.cs b/Samples/2a-validation/CSharp/Models/UsageUnit.cs index cf012fd42..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/Models/UsageUnit.cs +++ b/Samples/2a-validation/CSharp/Models/UsageUnit.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/StorageAccountsOperations.cs b/Samples/2a-validation/CSharp/StorageAccountsOperations.cs index 2a6ec2694..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/StorageAccountsOperations.cs +++ b/Samples/2a-validation/CSharp/StorageAccountsOperations.cs @@ -1,1947 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccountsOperations operations. - /// - internal partial class StorageAccountsOperations : IServiceOperations, IStorageAccountsOperations - { - /// - /// Initializes a new instance of the StorageAccountsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal StorageAccountsOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - accountName.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperties", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (regenerateKey == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "regenerateKey"); - } - if (regenerateKey != null) - { - regenerateKey.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/StorageAccountsOperationsExtensions.cs b/Samples/2a-validation/CSharp/StorageAccountsOperationsExtensions.cs index 75d0e6448..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/StorageAccountsOperationsExtensions.cs +++ b/Samples/2a-validation/CSharp/StorageAccountsOperationsExtensions.cs @@ -1,500 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccountsOperations. - /// - public static partial class StorageAccountsOperationsExtensions - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName) - { - return operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult(); - } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount Create(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static void Delete(this IStorageAccountsOperations operations, string resourceGroupName, string accountName) - { - operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static StorageAccount GetProperties(this IStorageAccountsOperations operations, string resourceGroupName, string accountName) - { - return operations.GetPropertiesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertiesAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - public static StorageAccount Update(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - public static StorageAccountKeys ListKeys(this IStorageAccountsOperations operations, string resourceGroupName, string accountName) - { - return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - public static IEnumerable List(this IStorageAccountsOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IStorageAccountsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - public static IEnumerable ListByResourceGroup(this IStorageAccountsOperations operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByResourceGroupAsync(this IStorageAccountsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - public static StorageAccountKeys RegenerateKey(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey) - { - return operations.RegenerateKeyAsync(resourceGroupName, accountName, regenerateKey).GetAwaiter().GetResult(); - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, regenerateKey, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount BeginCreate(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.BeginCreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/StorageManagementClient.cs b/Samples/2a-validation/CSharp/StorageManagementClient.cs index 83850d59e..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/StorageManagementClient.cs +++ b/Samples/2a-validation/CSharp/StorageManagementClient.cs @@ -1,323 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - - /// - /// The Storage Management Client. - /// - public partial class StorageManagementClient : ServiceClient, IStorageManagementClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - public string ApiVersion { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Gets the IStorageAccountsOperations. - /// - public virtual IStorageAccountsOperations StorageAccounts { get; private set; } - - /// - /// Gets the IUsageOperations. - /// - public virtual IUsageOperations Usage { get; private set; } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - StorageAccounts = new StorageAccountsOperations(this); - Usage = new UsageOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2015-06-15"; - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/UsageOperations.cs b/Samples/2a-validation/CSharp/UsageOperations.cs index 2fd6e5833..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/UsageOperations.cs +++ b/Samples/2a-validation/CSharp/UsageOperations.cs @@ -1,229 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - internal partial class UsageOperations : IServiceOperations, IUsageOperations - { - /// - /// Initializes a new instance of the UsageOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal UsageOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/CSharp/UsageOperationsExtensions.cs b/Samples/2a-validation/CSharp/UsageOperationsExtensions.cs index b479ca25a..9d6cafc2c 100644 --- a/Samples/2a-validation/CSharp/UsageOperationsExtensions.cs +++ b/Samples/2a-validation/CSharp/UsageOperationsExtensions.cs @@ -1,53 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsageOperations. - /// - public static partial class UsageOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IEnumerable List(this IUsageOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IUsageOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/StorageAccounts.java b/Samples/2a-validation/Java/StorageAccounts.java index 73fefb334..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/StorageAccounts.java +++ b/Samples/2a-validation/Java/StorageAccounts.java @@ -1,458 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import .models.CheckNameAvailabilityResult; -import .models.StorageAccount; -import .models.StorageAccountCheckNameAvailabilityParameters; -import .models.StorageAccountCreateParameters; -import .models.StorageAccountKeys; -import .models.StorageAccountRegenerateKeyParameters; -import .models.StorageAccountUpdateParameters; -import com.microsoft.azure.CloudException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import java.util.List; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in StorageAccounts. - */ -public interface StorageAccounts { - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the CheckNameAvailabilityResult object if successful. - */ - CheckNameAvailabilityResult checkNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, final ServiceCallback serviceCallback); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - Observable checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - Observable> checkNameAvailabilityWithServiceResponseAsync(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount beginCreate(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture beginCreateAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable beginCreateAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> beginCreateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void delete(String resourceGroupName, String accountName); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture deleteAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable deleteAsync(String resourceGroupName, String accountName); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount getProperties(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture getPropertiesAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable getPropertiesAsync(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> getPropertiesWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters, final ServiceCallback serviceCallback); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - StorageAccountKeys listKeys(String resourceGroupName, String accountName); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable listKeysAsync(String resourceGroupName, String accountName); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<StorageAccount> object if successful. - */ - List list(); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> listAsync(final ServiceCallback> serviceCallback); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - Observable> listAsync(); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - Observable>> listWithServiceResponseAsync(); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<StorageAccount> object if successful. - */ - List listByResourceGroup(String resourceGroupName); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> listByResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - Observable> listByResourceGroupAsync(String resourceGroupName); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - Observable>> listByResourceGroupWithServiceResponseAsync(String resourceGroupName); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - StorageAccountKeys regenerateKey(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey, final ServiceCallback serviceCallback); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/StorageManagementClient.java b/Samples/2a-validation/Java/StorageManagementClient.java index 7d407143d..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/StorageManagementClient.java +++ b/Samples/2a-validation/Java/StorageManagementClient.java @@ -1,115 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import com.microsoft.azure.AzureClient; -import com.microsoft.rest.RestClient; - -/** - * The interface for StorageManagementClient class. - */ -public interface StorageManagementClient { - /** - * Gets the REST client. - * - * @return the {@link RestClient} object. - */ - RestClient restClient(); - - /** - * Gets the {@link AzureClient} used for long running operations. - * @return the azure client; - */ - AzureClient getAzureClient(); - - /** - * Gets the User-Agent header for the client. - * - * @return the user agent string. - */ - String userAgent(); - - /** - * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. - * - * @return the subscriptionId value. - */ - String subscriptionId(); - - /** - * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. - * - * @param subscriptionId the subscriptionId value. - * @return the service client itself - */ - StorageManagementClient withSubscriptionId(String subscriptionId); - - /** - * Gets Client Api Version.. - * - * @return the apiVersion value. - */ - String apiVersion(); - - /** - * Gets Gets or sets the preferred language for the response.. - * - * @return the acceptLanguage value. - */ - String acceptLanguage(); - - /** - * Sets Gets or sets the preferred language for the response.. - * - * @param acceptLanguage the acceptLanguage value. - * @return the service client itself - */ - StorageManagementClient withAcceptLanguage(String acceptLanguage); - - /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. - * - * @return the longRunningOperationRetryTimeout value. - */ - int longRunningOperationRetryTimeout(); - - /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. - * - * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. - * @return the service client itself - */ - StorageManagementClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); - - /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. - * - * @return the generateClientRequestId value. - */ - boolean generateClientRequestId(); - - /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. - * - * @param generateClientRequestId the generateClientRequestId value. - * @return the service client itself - */ - StorageManagementClient withGenerateClientRequestId(boolean generateClientRequestId); - - /** - * Gets the StorageAccounts object to access its operations. - * @return the StorageAccounts object. - */ - StorageAccounts storageAccounts(); - - /** - * Gets the Usages object to access its operations. - * @return the Usages object. - */ - Usages usages(); - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/Usages.java b/Samples/2a-validation/Java/Usages.java index 0cc5b709c..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/Usages.java +++ b/Samples/2a-validation/Java/Usages.java @@ -1,58 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import .models.Usage; -import com.microsoft.azure.CloudException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import java.util.List; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Usages. - */ -public interface Usages { - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Usage> object if successful. - */ - List list(); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture> listAsync(final ServiceCallback> serviceCallback); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Usage> object - */ - Observable> listAsync(); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Usage> object - */ - Observable>> listWithServiceResponseAsync(); - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/implementation/StorageAccountsImpl.java b/Samples/2a-validation/Java/implementation/StorageAccountsImpl.java index 995bdcb6d..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/implementation/StorageAccountsImpl.java +++ b/Samples/2a-validation/Java/implementation/StorageAccountsImpl.java @@ -1,961 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import retrofit2.Retrofit; -import .StorageAccounts; -import .models.CheckNameAvailabilityResult; -import .models.PageImpl; -import .models.StorageAccount; -import .models.StorageAccountCheckNameAvailabilityParameters; -import .models.StorageAccountCreateParameters; -import .models.StorageAccountKeys; -import .models.StorageAccountRegenerateKeyParameters; -import .models.StorageAccountUpdateParameters; -import com.google.common.reflect.TypeToken; -import com.microsoft.azure.CloudException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.Validator; -import java.io.IOException; -import java.util.List; -import okhttp3.ResponseBody; -import retrofit2.http.Body; -import retrofit2.http.GET; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.HTTP; -import retrofit2.http.PATCH; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.http.PUT; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in StorageAccounts. - */ -public class StorageAccountsImpl implements StorageAccounts { - /** The Retrofit service to perform REST calls. */ - private StorageAccountsService service; - /** The service client containing this operation class. */ - private StorageManagementClientImpl client; - - /** - * Initializes an instance of StorageAccountsImpl. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public StorageAccountsImpl(Retrofit retrofit, StorageManagementClientImpl client) { - this.service = retrofit.create(StorageAccountsService.class); - this.client = client; - } - - /** - * The interface defining all the services for StorageAccounts to be - * used by Retrofit to perform actually REST calls. - */ - interface StorageAccountsService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts checkNameAvailability" }) - @POST("subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") - Observable> checkNameAvailability(@Path("subscriptionId") String subscriptionId, @Body StorageAccountCheckNameAvailabilityParameters accountName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts create" }) - @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> create(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountCreateParameters parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts beginCreate" }) - @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> beginCreate(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountCreateParameters parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts delete" }) - @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", method = "DELETE", hasBody = true) - Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts getProperties" }) - @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> getProperties(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts update" }) - @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountUpdateParameters parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts listKeys" }) - @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") - Observable> listKeys(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts list" }) - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") - Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts listByResourceGroup" }) - @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") - Observable> listByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts regenerateKey" }) - @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") - Observable> regenerateKey(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountRegenerateKeyParameters regenerateKey, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the CheckNameAvailabilityResult object if successful. - */ - public CheckNameAvailabilityResult checkNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName) { - return checkNameAvailabilityWithServiceResponseAsync(accountName).toBlocking().single().body(); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(checkNameAvailabilityWithServiceResponseAsync(accountName), serviceCallback); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - public Observable checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName) { - return checkNameAvailabilityWithServiceResponseAsync(accountName).map(new Func1, CheckNameAvailabilityResult>() { - @Override - public CheckNameAvailabilityResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - public Observable> checkNameAvailabilityWithServiceResponseAsync(StorageAccountCheckNameAvailabilityParameters accountName) { - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - Validator.validate(accountName); - return service.checkNameAvailability(this.client.subscriptionId(), accountName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = checkNameAvailabilityDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse checkNameAvailabilityDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().last().body(); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable for the request - */ - public Observable createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable for the request - */ - public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (parameters == null) { - throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - Validator.validate(parameters); - Observable> observable = service.create(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); - return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount beginCreate(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body(); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture beginCreateAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable beginCreateAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> beginCreateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (parameters == null) { - throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - Validator.validate(parameters); - return service.beginCreate(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = beginCreateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse beginCreateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .register(202, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void delete(String resourceGroupName, String accountName) { - deleteWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture deleteAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable deleteAsync(String resourceGroupName, String accountName) { - return deleteWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.delete(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .register(204, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount getProperties(String resourceGroupName, String accountName) { - return getPropertiesWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture getPropertiesAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(getPropertiesWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable getPropertiesAsync(String resourceGroupName, String accountName) { - return getPropertiesWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> getPropertiesWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.getProperties(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getPropertiesDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse getPropertiesDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body(); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (parameters == null) { - throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - Validator.validate(parameters); - return service.update(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - public StorageAccountKeys listKeys(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listKeysWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable listKeysAsync(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, StorageAccountKeys>() { - @Override - public StorageAccountKeys call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.listKeys(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listKeysDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listKeysDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<StorageAccount> object if successful. - */ - public List list() { - return listWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - public Observable> listAsync() { - return listWithServiceResponseAsync().map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - public Observable>> listWithServiceResponseAsync() { - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = listDelegate(response); - ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response()); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<StorageAccount> object if successful. - */ - public List listByResourceGroup(String resourceGroupName) { - return listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body(); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listByResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(listByResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - public Observable> listByResourceGroupAsync(String resourceGroupName) { - return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<StorageAccount> object - */ - public Observable>> listByResourceGroupWithServiceResponseAsync(String resourceGroupName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = listByResourceGroupDelegate(response); - ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response()); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse> listByResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - public StorageAccountKeys regenerateKey(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey).toBlocking().single().body(); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey), serviceCallback); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey).map(new Func1, StorageAccountKeys>() { - @Override - public StorageAccountKeys call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (regenerateKey == null) { - throw new IllegalArgumentException("Parameter regenerateKey is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - Validator.validate(regenerateKey); - return service.regenerateKey(resourceGroupName, accountName, this.client.subscriptionId(), regenerateKey, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = regenerateKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse regenerateKeyDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/implementation/StorageManagementClientImpl.java b/Samples/2a-validation/Java/implementation/StorageManagementClientImpl.java index 512d87879..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/implementation/StorageManagementClientImpl.java +++ b/Samples/2a-validation/Java/implementation/StorageManagementClientImpl.java @@ -1,211 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import .StorageAccounts; -import .StorageManagementClient; -import .Usages; -import com.microsoft.azure.AzureClient; -import com.microsoft.azure.AzureServiceClient; -import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.RestClient; - -/** - * Initializes a new instance of the StorageManagementClientImpl class. - */ -public class StorageManagementClientImpl extends AzureServiceClient implements StorageManagementClient { - /** the {@link AzureClient} used for long running operations. */ - private AzureClient azureClient; - - /** - * Gets the {@link AzureClient} used for long running operations. - * @return the azure client; - */ - public AzureClient getAzureClient() { - return this.azureClient; - } - - /** Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. */ - private String subscriptionId; - - /** - * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - * - * @return the subscriptionId value. - */ - public String subscriptionId() { - return this.subscriptionId; - } - - /** - * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - * - * @param subscriptionId the subscriptionId value. - * @return the service client itself - */ - public StorageManagementClientImpl withSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - return this; - } - - /** Client Api Version. */ - private String apiVersion; - - /** - * Gets Client Api Version. - * - * @return the apiVersion value. - */ - public String apiVersion() { - return this.apiVersion; - } - - /** Gets or sets the preferred language for the response. */ - private String acceptLanguage; - - /** - * Gets Gets or sets the preferred language for the response. - * - * @return the acceptLanguage value. - */ - public String acceptLanguage() { - return this.acceptLanguage; - } - - /** - * Sets Gets or sets the preferred language for the response. - * - * @param acceptLanguage the acceptLanguage value. - * @return the service client itself - */ - public StorageManagementClientImpl withAcceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - - /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ - private int longRunningOperationRetryTimeout; - - /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @return the longRunningOperationRetryTimeout value. - */ - public int longRunningOperationRetryTimeout() { - return this.longRunningOperationRetryTimeout; - } - - /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. - * @return the service client itself - */ - public StorageManagementClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { - this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; - return this; - } - - /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ - private boolean generateClientRequestId; - - /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @return the generateClientRequestId value. - */ - public boolean generateClientRequestId() { - return this.generateClientRequestId; - } - - /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @param generateClientRequestId the generateClientRequestId value. - * @return the service client itself - */ - public StorageManagementClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { - this.generateClientRequestId = generateClientRequestId; - return this; - } - - /** - * The StorageAccounts object to access its operations. - */ - private StorageAccounts storageAccounts; - - /** - * Gets the StorageAccounts object to access its operations. - * @return the StorageAccounts object. - */ - public StorageAccounts storageAccounts() { - return this.storageAccounts; - } - - /** - * The Usages object to access its operations. - */ - private Usages usages; - - /** - * Gets the Usages object to access its operations. - * @return the Usages object. - */ - public Usages usages() { - return this.usages; - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param credentials the management credentials for Azure - */ - public StorageManagementClientImpl(ServiceClientCredentials credentials) { - this("https://management.azure.com", credentials); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param baseUrl the base URL of the host - * @param credentials the management credentials for Azure - */ - public StorageManagementClientImpl(String baseUrl, ServiceClientCredentials credentials) { - super(baseUrl, credentials); - initialize(); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param restClient the REST client to connect to Azure. - */ - public StorageManagementClientImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - protected void initialize() { - this.apiVersion = "2015-06-15"; - this.acceptLanguage = "en-US"; - this.longRunningOperationRetryTimeout = 30; - this.generateClientRequestId = true; - this.storageAccounts = new StorageAccountsImpl(restClient().retrofit(), this); - this.usages = new UsagesImpl(restClient().retrofit(), this); - this.azureClient = new AzureClient(this); - } - - /** - * Gets the User-Agent header for the client. - * - * @return the user agent string. - */ - @Override - public String userAgent() { - return String.format("%s (%s, %s)", super.userAgent(), "StorageManagementClient", "2015-06-15"); - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/implementation/UsagesImpl.java b/Samples/2a-validation/Java/implementation/UsagesImpl.java index cbab692bc..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/implementation/UsagesImpl.java +++ b/Samples/2a-validation/Java/implementation/UsagesImpl.java @@ -1,135 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import retrofit2.Retrofit; -import .Usages; -import .models.PageImpl; -import .models.Usage; -import com.google.common.reflect.TypeToken; -import com.microsoft.azure.CloudException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import java.util.List; -import okhttp3.ResponseBody; -import retrofit2.http.GET; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Usages. - */ -public class UsagesImpl implements Usages { - /** The Retrofit service to perform REST calls. */ - private UsagesService service; - /** The service client containing this operation class. */ - private StorageManagementClientImpl client; - - /** - * Initializes an instance of UsagesImpl. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public UsagesImpl(Retrofit retrofit, StorageManagementClientImpl client) { - this.service = retrofit.create(UsagesService.class); - this.client = client; - } - - /** - * The interface defining all the services for Usages to be - * used by Retrofit to perform actually REST calls. - */ - interface UsagesService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .Usages list" }) - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") - Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws CloudException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Usage> object if successful. - */ - public List list() { - return listWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Usage> object - */ - public Observable> listAsync() { - return listWithServiceResponseAsync().map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Usage> object - */ - public Observable>> listWithServiceResponseAsync() { - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = listDelegate(response); - ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response()); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken>() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/implementation/package-info.java b/Samples/2a-validation/Java/implementation/package-info.java index 0c19b9bfc..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/implementation/package-info.java +++ b/Samples/2a-validation/Java/implementation/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage.implementation; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/AccountStatus.java b/Samples/2a-validation/Java/models/AccountStatus.java index 20ee2a21e..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/AccountStatus.java +++ b/Samples/2a-validation/Java/models/AccountStatus.java @@ -1,51 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for AccountStatus. - */ -public enum AccountStatus { - /** Enum value Available. */ - AVAILABLE("Available"), - - /** Enum value Unavailable. */ - UNAVAILABLE("Unavailable"); - - /** The actual serialized value for a AccountStatus instance. */ - private String value; - - AccountStatus(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AccountStatus instance. - * - * @param value the serialized value to parse. - * @return the parsed AccountStatus object, or null if unable to parse. - */ - @JsonCreator - public static AccountStatus fromString(String value) { - AccountStatus[] items = AccountStatus.values(); - for (AccountStatus item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/AccountType.java b/Samples/2a-validation/Java/models/AccountType.java index d01ec02b5..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/AccountType.java +++ b/Samples/2a-validation/Java/models/AccountType.java @@ -1,60 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for AccountType. - */ -public enum AccountType { - /** Enum value Standard_LRS. */ - STANDARD_LRS("Standard_LRS"), - - /** Enum value Standard_ZRS. */ - STANDARD_ZRS("Standard_ZRS"), - - /** Enum value Standard_GRS. */ - STANDARD_GRS("Standard_GRS"), - - /** Enum value Standard_RAGRS. */ - STANDARD_RAGRS("Standard_RAGRS"), - - /** Enum value Premium_LRS. */ - PREMIUM_LRS("Premium_LRS"); - - /** The actual serialized value for a AccountType instance. */ - private String value; - - AccountType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AccountType instance. - * - * @param value the serialized value to parse. - * @return the parsed AccountType object, or null if unable to parse. - */ - @JsonCreator - public static AccountType fromString(String value) { - AccountType[] items = AccountType.values(); - for (AccountType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/CheckNameAvailabilityResult.java b/Samples/2a-validation/Java/models/CheckNameAvailabilityResult.java index 5a0f4514a..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/CheckNameAvailabilityResult.java +++ b/Samples/2a-validation/Java/models/CheckNameAvailabilityResult.java @@ -1,97 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The CheckNameAvailability operation response. - */ -public class CheckNameAvailabilityResult { - /** - * Gets a boolean value that indicates whether the name is available for - * you to use. If true, the name is available. If false, the name has - * already been taken or invalid and cannot be used. - */ - @JsonProperty(value = "nameAvailable") - private Boolean nameAvailable; - - /** - * Gets the reason that a storage account name could not be used. The - * Reason element is only returned if NameAvailable is false. Possible - * values include: 'AccountNameInvalid', 'AlreadyExists'. - */ - @JsonProperty(value = "reason") - private Reason reason; - - /** - * Gets an error message explaining the Reason value in more detail. - */ - @JsonProperty(value = "message") - private String message; - - /** - * Get the nameAvailable value. - * - * @return the nameAvailable value - */ - public Boolean nameAvailable() { - return this.nameAvailable; - } - - /** - * Set the nameAvailable value. - * - * @param nameAvailable the nameAvailable value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withNameAvailable(Boolean nameAvailable) { - this.nameAvailable = nameAvailable; - return this; - } - - /** - * Get the reason value. - * - * @return the reason value - */ - public Reason reason() { - return this.reason; - } - - /** - * Set the reason value. - * - * @param reason the reason value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withReason(Reason reason) { - this.reason = reason; - return this; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } - - /** - * Set the message value. - * - * @param message the message value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withMessage(String message) { - this.message = message; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/CustomDomain.java b/Samples/2a-validation/Java/models/CustomDomain.java index f7e791460..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/CustomDomain.java +++ b/Samples/2a-validation/Java/models/CustomDomain.java @@ -1,69 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The custom domain assigned to this storage account. This can be set via - * Update. - */ -public class CustomDomain { - /** - * Gets or sets the custom domain name. Name is the CNAME source. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * Indicates whether indirect CName validation is enabled. Default value is - * false. This should only be set on updates. - */ - @JsonProperty(value = "useSubDomain") - private Boolean useSubDomain; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the CustomDomain object itself. - */ - public CustomDomain withName(String name) { - this.name = name; - return this; - } - - /** - * Get the useSubDomain value. - * - * @return the useSubDomain value - */ - public Boolean useSubDomain() { - return this.useSubDomain; - } - - /** - * Set the useSubDomain value. - * - * @param useSubDomain the useSubDomain value to set - * @return the CustomDomain object itself. - */ - public CustomDomain withUseSubDomain(Boolean useSubDomain) { - this.useSubDomain = useSubDomain; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/Endpoints.java b/Samples/2a-validation/Java/models/Endpoints.java index 4359afdea..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/Endpoints.java +++ b/Samples/2a-validation/Java/models/Endpoints.java @@ -1,120 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The URIs that are used to perform a retrieval of a public blob, queue or - * table object. - */ -public class Endpoints { - /** - * Gets the blob endpoint. - */ - @JsonProperty(value = "blob") - private String blob; - - /** - * Gets the queue endpoint. - */ - @JsonProperty(value = "queue") - private String queue; - - /** - * Gets the table endpoint. - */ - @JsonProperty(value = "table") - private String table; - - /** - * Gets the file endpoint. - */ - @JsonProperty(value = "file") - private String file; - - /** - * Get the blob value. - * - * @return the blob value - */ - public String blob() { - return this.blob; - } - - /** - * Set the blob value. - * - * @param blob the blob value to set - * @return the Endpoints object itself. - */ - public Endpoints withBlob(String blob) { - this.blob = blob; - return this; - } - - /** - * Get the queue value. - * - * @return the queue value - */ - public String queue() { - return this.queue; - } - - /** - * Set the queue value. - * - * @param queue the queue value to set - * @return the Endpoints object itself. - */ - public Endpoints withQueue(String queue) { - this.queue = queue; - return this; - } - - /** - * Get the table value. - * - * @return the table value - */ - public String table() { - return this.table; - } - - /** - * Set the table value. - * - * @param table the table value to set - * @return the Endpoints object itself. - */ - public Endpoints withTable(String table) { - this.table = table; - return this; - } - - /** - * Get the file value. - * - * @return the file value - */ - public String file() { - return this.file; - } - - /** - * Set the file value. - * - * @param file the file value to set - * @return the Endpoints object itself. - */ - public Endpoints withFile(String file) { - this.file = file; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/PageImpl.java b/Samples/2a-validation/Java/models/PageImpl.java index 41bc23e8c..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/PageImpl.java +++ b/Samples/2a-validation/Java/models/PageImpl.java @@ -1,73 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.azure.Page; -import java.util.List; - -/** - * An instance of this class defines a page of Azure resources and a link to - * get the next page of resources, if any. - * - * @param type of Azure resource - */ -public class PageImpl implements Page { - /** - * The link to the next page. - */ - @JsonProperty("") - private String nextPageLink; - - /** - * The list of items. - */ - @JsonProperty("value") - private List items; - - /** - * Gets the link to the next page. - * - * @return the link to the next page. - */ - @Override - public String nextPageLink() { - return this.nextPageLink; - } - - /** - * Gets the list of items. - * - * @return the list of items in {@link List}. - */ - @Override - public List items() { - return items; - } - - /** - * Sets the link to the next page. - * - * @param nextPageLink the link to the next page. - * @return this Page object itself. - */ - public PageImpl setNextPageLink(String nextPageLink) { - this.nextPageLink = nextPageLink; - return this; - } - - /** - * Sets the list of items. - * - * @param items the list of items in {@link List}. - * @return this Page object itself. - */ - public PageImpl setItems(List items) { - this.items = items; - return this; - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/ProvisioningState.java b/Samples/2a-validation/Java/models/ProvisioningState.java index 215602add..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/ProvisioningState.java +++ b/Samples/2a-validation/Java/models/ProvisioningState.java @@ -1,54 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ProvisioningState. - */ -public enum ProvisioningState { - /** Enum value Creating. */ - CREATING("Creating"), - - /** Enum value ResolvingDNS. */ - RESOLVING_DNS("ResolvingDNS"), - - /** Enum value Succeeded. */ - SUCCEEDED("Succeeded"); - - /** The actual serialized value for a ProvisioningState instance. */ - private String value; - - ProvisioningState(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ProvisioningState instance. - * - * @param value the serialized value to parse. - * @return the parsed ProvisioningState object, or null if unable to parse. - */ - @JsonCreator - public static ProvisioningState fromString(String value) { - ProvisioningState[] items = ProvisioningState.values(); - for (ProvisioningState item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/Reason.java b/Samples/2a-validation/Java/models/Reason.java index e1fbd1391..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/Reason.java +++ b/Samples/2a-validation/Java/models/Reason.java @@ -1,51 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for Reason. - */ -public enum Reason { - /** Enum value AccountNameInvalid. */ - ACCOUNT_NAME_INVALID("AccountNameInvalid"), - - /** Enum value AlreadyExists. */ - ALREADY_EXISTS("AlreadyExists"); - - /** The actual serialized value for a Reason instance. */ - private String value; - - Reason(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a Reason instance. - * - * @param value the serialized value to parse. - * @return the parsed Reason object, or null if unable to parse. - */ - @JsonCreator - public static Reason fromString(String value) { - Reason[] items = Reason.values(); - for (Reason item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/StorageAccount.java b/Samples/2a-validation/Java/models/StorageAccount.java index e5017a469..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/StorageAccount.java +++ b/Samples/2a-validation/Java/models/StorageAccount.java @@ -1,323 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import org.joda.time.DateTime; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; -import com.microsoft.azure.Resource; - -/** - * The storage account. - */ -@JsonFlatten -public class StorageAccount extends Resource { - /** - * Gets the status of the storage account at the time the operation was - * called. Possible values include: 'Creating', 'ResolvingDNS', - * 'Succeeded'. - */ - @JsonProperty(value = "properties.provisioningState") - private ProvisioningState provisioningState; - - /** - * Gets the type of the storage account. Possible values include: - * 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - * 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType") - private AccountType accountType; - - /** - * Gets the URLs that are used to perform a retrieval of a public blob, - * queue or table object.Note that StandardZRS and PremiumLRS accounts only - * return the blob endpoint. - */ - @JsonProperty(value = "properties.primaryEndpoints") - private Endpoints primaryEndpoints; - - /** - * Gets the location of the primary for the storage account. - */ - @JsonProperty(value = "properties.primaryLocation") - private String primaryLocation; - - /** - * Gets the status indicating whether the primary location of the storage - * account is available or unavailable. Possible values include: - * 'Available', 'Unavailable'. - */ - @JsonProperty(value = "properties.statusOfPrimary") - private AccountStatus statusOfPrimary; - - /** - * Gets the timestamp of the most recent instance of a failover to the - * secondary location. Only the most recent timestamp is retained. This - * element is not returned if there has never been a failover instance. - * Only available if the accountType is StandardGRS or StandardRAGRS. - */ - @JsonProperty(value = "properties.lastGeoFailoverTime") - private DateTime lastGeoFailoverTime; - - /** - * Gets the location of the geo replicated secondary for the storage - * account. Only available if the accountType is StandardGRS or - * StandardRAGRS. - */ - @JsonProperty(value = "properties.secondaryLocation") - private String secondaryLocation; - - /** - * Gets the status indicating whether the secondary location of the storage - * account is available or unavailable. Only available if the accountType - * is StandardGRS or StandardRAGRS. Possible values include: 'Available', - * 'Unavailable'. - */ - @JsonProperty(value = "properties.statusOfSecondary") - private AccountStatus statusOfSecondary; - - /** - * Gets the creation date and time of the storage account in UTC. - */ - @JsonProperty(value = "properties.creationTime") - private DateTime creationTime; - - /** - * Gets the user assigned custom domain assigned to this storage account. - */ - @JsonProperty(value = "properties.customDomain") - private CustomDomain customDomain; - - /** - * Gets the URLs that are used to perform a retrieval of a public blob, - * queue or table object from the secondary location of the storage - * account. Only available if the accountType is StandardRAGRS. - */ - @JsonProperty(value = "properties.secondaryEndpoints") - private Endpoints secondaryEndpoints; - - /** - * Get the provisioningState value. - * - * @return the provisioningState value - */ - public ProvisioningState provisioningState() { - return this.provisioningState; - } - - /** - * Set the provisioningState value. - * - * @param provisioningState the provisioningState value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withProvisioningState(ProvisioningState provisioningState) { - this.provisioningState = provisioningState; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - - /** - * Get the primaryEndpoints value. - * - * @return the primaryEndpoints value - */ - public Endpoints primaryEndpoints() { - return this.primaryEndpoints; - } - - /** - * Set the primaryEndpoints value. - * - * @param primaryEndpoints the primaryEndpoints value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withPrimaryEndpoints(Endpoints primaryEndpoints) { - this.primaryEndpoints = primaryEndpoints; - return this; - } - - /** - * Get the primaryLocation value. - * - * @return the primaryLocation value - */ - public String primaryLocation() { - return this.primaryLocation; - } - - /** - * Set the primaryLocation value. - * - * @param primaryLocation the primaryLocation value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withPrimaryLocation(String primaryLocation) { - this.primaryLocation = primaryLocation; - return this; - } - - /** - * Get the statusOfPrimary value. - * - * @return the statusOfPrimary value - */ - public AccountStatus statusOfPrimary() { - return this.statusOfPrimary; - } - - /** - * Set the statusOfPrimary value. - * - * @param statusOfPrimary the statusOfPrimary value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withStatusOfPrimary(AccountStatus statusOfPrimary) { - this.statusOfPrimary = statusOfPrimary; - return this; - } - - /** - * Get the lastGeoFailoverTime value. - * - * @return the lastGeoFailoverTime value - */ - public DateTime lastGeoFailoverTime() { - return this.lastGeoFailoverTime; - } - - /** - * Set the lastGeoFailoverTime value. - * - * @param lastGeoFailoverTime the lastGeoFailoverTime value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withLastGeoFailoverTime(DateTime lastGeoFailoverTime) { - this.lastGeoFailoverTime = lastGeoFailoverTime; - return this; - } - - /** - * Get the secondaryLocation value. - * - * @return the secondaryLocation value - */ - public String secondaryLocation() { - return this.secondaryLocation; - } - - /** - * Set the secondaryLocation value. - * - * @param secondaryLocation the secondaryLocation value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withSecondaryLocation(String secondaryLocation) { - this.secondaryLocation = secondaryLocation; - return this; - } - - /** - * Get the statusOfSecondary value. - * - * @return the statusOfSecondary value - */ - public AccountStatus statusOfSecondary() { - return this.statusOfSecondary; - } - - /** - * Set the statusOfSecondary value. - * - * @param statusOfSecondary the statusOfSecondary value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withStatusOfSecondary(AccountStatus statusOfSecondary) { - this.statusOfSecondary = statusOfSecondary; - return this; - } - - /** - * Get the creationTime value. - * - * @return the creationTime value - */ - public DateTime creationTime() { - return this.creationTime; - } - - /** - * Set the creationTime value. - * - * @param creationTime the creationTime value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withCreationTime(DateTime creationTime) { - this.creationTime = creationTime; - return this; - } - - /** - * Get the customDomain value. - * - * @return the customDomain value - */ - public CustomDomain customDomain() { - return this.customDomain; - } - - /** - * Set the customDomain value. - * - * @param customDomain the customDomain value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withCustomDomain(CustomDomain customDomain) { - this.customDomain = customDomain; - return this; - } - - /** - * Get the secondaryEndpoints value. - * - * @return the secondaryEndpoints value - */ - public Endpoints secondaryEndpoints() { - return this.secondaryEndpoints; - } - - /** - * Set the secondaryEndpoints value. - * - * @param secondaryEndpoints the secondaryEndpoints value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withSecondaryEndpoints(Endpoints secondaryEndpoints) { - this.secondaryEndpoints = secondaryEndpoints; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/StorageAccountCheckNameAvailabilityParameters.java b/Samples/2a-validation/Java/models/StorageAccountCheckNameAvailabilityParameters.java index b34de88bf..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/StorageAccountCheckNameAvailabilityParameters.java +++ b/Samples/2a-validation/Java/models/StorageAccountCheckNameAvailabilityParameters.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The StorageAccountCheckNameAvailabilityParameters model. - */ -public class StorageAccountCheckNameAvailabilityParameters { - /** - * The name property. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * The type property. - */ - @JsonProperty(value = "type") - private String type; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the StorageAccountCheckNameAvailabilityParameters object itself. - */ - public StorageAccountCheckNameAvailabilityParameters withName(String name) { - this.name = name; - return this; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the StorageAccountCheckNameAvailabilityParameters object itself. - */ - public StorageAccountCheckNameAvailabilityParameters withType(String type) { - this.type = type; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/StorageAccountCreateParameters.java b/Samples/2a-validation/Java/models/StorageAccountCreateParameters.java index 58aa37ec1..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/StorageAccountCreateParameters.java +++ b/Samples/2a-validation/Java/models/StorageAccountCreateParameters.java @@ -1,97 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The parameters to provide for the account. - */ -@JsonFlatten -public class StorageAccountCreateParameters { - /** - * Resource location. - */ - @JsonProperty(value = "location", required = true) - private String location; - - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Gets or sets the account type. Possible values include: 'Standard_LRS', - * 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType", required = true) - private AccountType accountType; - - /** - * Get the location value. - * - * @return the location value - */ - public String location() { - return this.location; - } - - /** - * Set the location value. - * - * @param location the location value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withLocation(String location) { - this.location = location; - return this; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/StorageAccountKeys.java b/Samples/2a-validation/Java/models/StorageAccountKeys.java index 03b769713..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/StorageAccountKeys.java +++ b/Samples/2a-validation/Java/models/StorageAccountKeys.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The access keys for the storage account. - */ -public class StorageAccountKeys { - /** - * Gets the value of key 1. - */ - @JsonProperty(value = "key1") - private String key1; - - /** - * Gets the value of key 2. - */ - @JsonProperty(value = "key2") - private String key2; - - /** - * Get the key1 value. - * - * @return the key1 value - */ - public String key1() { - return this.key1; - } - - /** - * Set the key1 value. - * - * @param key1 the key1 value to set - * @return the StorageAccountKeys object itself. - */ - public StorageAccountKeys withKey1(String key1) { - this.key1 = key1; - return this; - } - - /** - * Get the key2 value. - * - * @return the key2 value - */ - public String key2() { - return this.key2; - } - - /** - * Set the key2 value. - * - * @param key2 the key2 value to set - * @return the StorageAccountKeys object itself. - */ - public StorageAccountKeys withKey2(String key2) { - this.key2 = key2; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/StorageAccountRegenerateKeyParameters.java b/Samples/2a-validation/Java/models/StorageAccountRegenerateKeyParameters.java index 90892708f..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/StorageAccountRegenerateKeyParameters.java +++ b/Samples/2a-validation/Java/models/StorageAccountRegenerateKeyParameters.java @@ -1,41 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The StorageAccountRegenerateKeyParameters model. - */ -public class StorageAccountRegenerateKeyParameters { - /** - * The keyName property. - */ - @JsonProperty(value = "keyName", required = true) - private String keyName; - - /** - * Get the keyName value. - * - * @return the keyName value - */ - public String keyName() { - return this.keyName; - } - - /** - * Set the keyName value. - * - * @param keyName the keyName value to set - * @return the StorageAccountRegenerateKeyParameters object itself. - */ - public StorageAccountRegenerateKeyParameters withKeyName(String keyName) { - this.keyName = keyName; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/StorageAccountUpdateParameters.java b/Samples/2a-validation/Java/models/StorageAccountUpdateParameters.java index d1958668c..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/StorageAccountUpdateParameters.java +++ b/Samples/2a-validation/Java/models/StorageAccountUpdateParameters.java @@ -1,103 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The parameters to update on the account. - */ -@JsonFlatten -public class StorageAccountUpdateParameters { - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Gets or sets the account type. Note that StandardZRS and PremiumLRS - * accounts cannot be changed to other account types, and other account - * types cannot be changed to StandardZRS or PremiumLRS. Possible values - * include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType") - private AccountType accountType; - - /** - * User domain assigned to the storage account. Name is the CNAME source. - * Only one custom domain is supported per storage account at this time. To - * clear the existing custom domain, use an empty string for the custom - * domain name property. - */ - @JsonProperty(value = "properties.customDomain") - private CustomDomain customDomain; - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - - /** - * Get the customDomain value. - * - * @return the customDomain value - */ - public CustomDomain customDomain() { - return this.customDomain; - } - - /** - * Set the customDomain value. - * - * @param customDomain the customDomain value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withCustomDomain(CustomDomain customDomain) { - this.customDomain = customDomain; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/Usage.java b/Samples/2a-validation/Java/models/Usage.java index 45b3bf140..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/Usage.java +++ b/Samples/2a-validation/Java/models/Usage.java @@ -1,121 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Describes Storage Resource Usage. - */ -public class Usage { - /** - * Gets the unit of measurement. Possible values include: 'Count', 'Bytes', - * 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond'. - */ - @JsonProperty(value = "unit", required = true) - private UsageUnit unit; - - /** - * Gets the current count of the allocated resources in the subscription. - */ - @JsonProperty(value = "currentValue", required = true) - private int currentValue; - - /** - * Gets the maximum count of the resources that can be allocated in the - * subscription. - */ - @JsonProperty(value = "limit", required = true) - private int limit; - - /** - * Gets the name of the type of usage. - */ - @JsonProperty(value = "name", required = true) - private UsageName name; - - /** - * Get the unit value. - * - * @return the unit value - */ - public UsageUnit unit() { - return this.unit; - } - - /** - * Set the unit value. - * - * @param unit the unit value to set - * @return the Usage object itself. - */ - public Usage withUnit(UsageUnit unit) { - this.unit = unit; - return this; - } - - /** - * Get the currentValue value. - * - * @return the currentValue value - */ - public int currentValue() { - return this.currentValue; - } - - /** - * Set the currentValue value. - * - * @param currentValue the currentValue value to set - * @return the Usage object itself. - */ - public Usage withCurrentValue(int currentValue) { - this.currentValue = currentValue; - return this; - } - - /** - * Get the limit value. - * - * @return the limit value - */ - public int limit() { - return this.limit; - } - - /** - * Set the limit value. - * - * @param limit the limit value to set - * @return the Usage object itself. - */ - public Usage withLimit(int limit) { - this.limit = limit; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public UsageName name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Usage object itself. - */ - public Usage withName(UsageName name) { - this.name = name; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/UsageName.java b/Samples/2a-validation/Java/models/UsageName.java index a0f2dffd5..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/UsageName.java +++ b/Samples/2a-validation/Java/models/UsageName.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Usage Names. - */ -public class UsageName { - /** - * Gets a string describing the resource name. - */ - @JsonProperty(value = "value") - private String value; - - /** - * Gets a localized string describing the resource name. - */ - @JsonProperty(value = "localizedValue") - private String localizedValue; - - /** - * Get the value value. - * - * @return the value value - */ - public String value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the UsageName object itself. - */ - public UsageName withValue(String value) { - this.value = value; - return this; - } - - /** - * Get the localizedValue value. - * - * @return the localizedValue value - */ - public String localizedValue() { - return this.localizedValue; - } - - /** - * Set the localizedValue value. - * - * @param localizedValue the localizedValue value to set - * @return the UsageName object itself. - */ - public UsageName withLocalizedValue(String localizedValue) { - this.localizedValue = localizedValue; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/UsageUnit.java b/Samples/2a-validation/Java/models/UsageUnit.java index 3c205be70..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/UsageUnit.java +++ b/Samples/2a-validation/Java/models/UsageUnit.java @@ -1,63 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for UsageUnit. - */ -public enum UsageUnit { - /** Enum value Count. */ - COUNT("Count"), - - /** Enum value Bytes. */ - BYTES("Bytes"), - - /** Enum value Seconds. */ - SECONDS("Seconds"), - - /** Enum value Percent. */ - PERCENT("Percent"), - - /** Enum value CountsPerSecond. */ - COUNTS_PER_SECOND("CountsPerSecond"), - - /** Enum value BytesPerSecond. */ - BYTES_PER_SECOND("BytesPerSecond"); - - /** The actual serialized value for a UsageUnit instance. */ - private String value; - - UsageUnit(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a UsageUnit instance. - * - * @param value the serialized value to parse. - * @return the parsed UsageUnit object, or null if unable to parse. - */ - @JsonCreator - public static UsageUnit fromString(String value) { - UsageUnit[] items = UsageUnit.values(); - for (UsageUnit item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/models/package-info.java b/Samples/2a-validation/Java/models/package-info.java index 17e1cbb51..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/models/package-info.java +++ b/Samples/2a-validation/Java/models/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the models classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage.models; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Java/package-info.java b/Samples/2a-validation/Java/package-info.java index 325714cc1..9d6cafc2c 100644 --- a/Samples/2a-validation/Java/package-info.java +++ b/Samples/2a-validation/Java/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/checkNameAvailabilityResult.js b/Samples/2a-validation/NodeJS/models/checkNameAvailabilityResult.js index 7f17e109d..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/checkNameAvailabilityResult.js +++ b/Samples/2a-validation/NodeJS/models/checkNameAvailabilityResult.js @@ -1,71 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * The CheckNameAvailability operation response. - * - */ -class CheckNameAvailabilityResult { - /** - * Create a CheckNameAvailabilityResult. - * @member {boolean} [nameAvailable] Gets a boolean value that indicates - * whether the name is available for you to use. If true, the name is - * available. If false, the name has already been taken or invalid and cannot - * be used. - * @member {string} [reason] Gets the reason that a storage account name - * could not be used. The Reason element is only returned if NameAvailable is - * false. Possible values include: 'AccountNameInvalid', 'AlreadyExists' - * @member {string} [message] Gets an error message explaining the Reason - * value in more detail. - */ - constructor() { - } - - /** - * Defines the metadata of CheckNameAvailabilityResult - * - * @returns {object} metadata of CheckNameAvailabilityResult - * - */ - mapper() { - return { - required: false, - serializedName: 'CheckNameAvailabilityResult', - type: { - name: 'Composite', - className: 'CheckNameAvailabilityResult', - modelProperties: { - nameAvailable: { - required: false, - serializedName: 'nameAvailable', - type: { - name: 'Boolean' - } - }, - reason: { - required: false, - serializedName: 'reason', - type: { - name: 'Enum', - allowedValues: [ 'AccountNameInvalid', 'AlreadyExists' ] - } - }, - message: { - required: false, - serializedName: 'message', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = CheckNameAvailabilityResult; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/customDomain.js b/Samples/2a-validation/NodeJS/models/customDomain.js index 8bc00b145..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/customDomain.js +++ b/Samples/2a-validation/NodeJS/models/customDomain.js @@ -1,60 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * The custom domain assigned to this storage account. This can be set via - * Update. - * - */ -class CustomDomain { - /** - * Create a CustomDomain. - * @member {string} name Gets or sets the custom domain name. Name is the - * CNAME source. - * @member {boolean} [useSubDomain] Indicates whether indirect CName - * validation is enabled. Default value is false. This should only be set on - * updates - */ - constructor() { - } - - /** - * Defines the metadata of CustomDomain - * - * @returns {object} metadata of CustomDomain - * - */ - mapper() { - return { - required: false, - serializedName: 'CustomDomain', - type: { - name: 'Composite', - className: 'CustomDomain', - modelProperties: { - name: { - required: true, - serializedName: 'name', - type: { - name: 'String' - } - }, - useSubDomain: { - required: false, - serializedName: 'useSubDomain', - type: { - name: 'Boolean' - } - } - } - } - }; - } -} - -module.exports = CustomDomain; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/endpoints.js b/Samples/2a-validation/NodeJS/models/endpoints.js index 0e6f8b8e8..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/endpoints.js +++ b/Samples/2a-validation/NodeJS/models/endpoints.js @@ -1,73 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * The URIs that are used to perform a retrieval of a public blob, queue or - * table object. - * - */ -class Endpoints { - /** - * Create a Endpoints. - * @member {string} [blob] Gets the blob endpoint. - * @member {string} [queue] Gets the queue endpoint. - * @member {string} [table] Gets the table endpoint. - * @member {string} [file] Gets the file endpoint. - */ - constructor() { - } - - /** - * Defines the metadata of Endpoints - * - * @returns {object} metadata of Endpoints - * - */ - mapper() { - return { - required: false, - serializedName: 'Endpoints', - type: { - name: 'Composite', - className: 'Endpoints', - modelProperties: { - blob: { - required: false, - serializedName: 'blob', - type: { - name: 'String' - } - }, - queue: { - required: false, - serializedName: 'queue', - type: { - name: 'String' - } - }, - table: { - required: false, - serializedName: 'table', - type: { - name: 'String' - } - }, - file: { - required: false, - serializedName: 'file', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = Endpoints; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/index.js b/Samples/2a-validation/NodeJS/models/index.js index d24edc4db..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/index.js +++ b/Samples/2a-validation/NodeJS/models/index.js @@ -1,30 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -var msRestAzure = require('ms-rest-azure'); - -exports.BaseResource = msRestAzure.BaseResource; -exports.CloudError = msRestAzure.CloudError; -exports.StorageAccountCheckNameAvailabilityParameters = require('./storageAccountCheckNameAvailabilityParameters'); -exports.CheckNameAvailabilityResult = require('./checkNameAvailabilityResult'); -exports.StorageAccountCreateParameters = require('./storageAccountCreateParameters'); -exports.Endpoints = require('./endpoints'); -exports.CustomDomain = require('./customDomain'); -exports.Resource = require('./resource'); -exports.StorageAccount = require('./storageAccount'); -exports.StorageAccountKeys = require('./storageAccountKeys'); -exports.StorageAccountUpdateParameters = require('./storageAccountUpdateParameters'); -exports.StorageAccountRegenerateKeyParameters = require('./storageAccountRegenerateKeyParameters'); -exports.UsageName = require('./usageName'); -exports.Usage = require('./usage'); -exports.StorageAccountListResult = require('./storageAccountListResult'); -exports.UsageListResult = require('./usageListResult'); +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/resource.js b/Samples/2a-validation/NodeJS/models/resource.js index 2bed9314f..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/resource.js +++ b/Samples/2a-validation/NodeJS/models/resource.js @@ -1,93 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const models = require('./index'); - -/** - * Class representing a Resource. - * @extends models['BaseResource'] - */ -class Resource extends models['BaseResource'] { - /** - * Create a Resource. - * @member {string} [id] Resource Id - * @member {string} [name] Resource name - * @member {string} [type] Resource type - * @member {string} [location] Resource location - * @member {object} [tags] Resource tags - */ - constructor() { - super(); - } - - /** - * Defines the metadata of Resource - * - * @returns {object} metadata of Resource - * - */ - mapper() { - return { - required: false, - serializedName: 'Resource', - type: { - name: 'Composite', - className: 'Resource', - modelProperties: { - id: { - required: false, - readOnly: true, - serializedName: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - readOnly: true, - serializedName: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - readOnly: true, - serializedName: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serializedName: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serializedName: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serializedName: 'StringElementType', - type: { - name: 'String' - } - } - } - } - } - } - }; - } -} - -module.exports = Resource; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/storageAccount.js b/Samples/2a-validation/NodeJS/models/storageAccount.js index e36a1f994..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/storageAccount.js +++ b/Samples/2a-validation/NodeJS/models/storageAccount.js @@ -1,220 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const models = require('./index'); - -/** - * The storage account. - * - * @extends models['Resource'] - */ -class StorageAccount extends models['Resource'] { - /** - * Create a StorageAccount. - * @member {string} [provisioningState] Gets the status of the storage - * account at the time the operation was called. Possible values include: - * 'Creating', 'ResolvingDNS', 'Succeeded' - * @member {string} [accountType] Gets the type of the storage account. - * Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - * @member {object} [primaryEndpoints] Gets the URLs that are used to perform - * a retrieval of a public blob, queue or table object.Note that StandardZRS - * and PremiumLRS accounts only return the blob endpoint. - * @member {string} [primaryEndpoints.blob] Gets the blob endpoint. - * @member {string} [primaryEndpoints.queue] Gets the queue endpoint. - * @member {string} [primaryEndpoints.table] Gets the table endpoint. - * @member {string} [primaryEndpoints.file] Gets the file endpoint. - * @member {string} [primaryLocation] Gets the location of the primary for - * the storage account. - * @member {string} [statusOfPrimary] Gets the status indicating whether the - * primary location of the storage account is available or unavailable. - * Possible values include: 'Available', 'Unavailable' - * @member {date} [lastGeoFailoverTime] Gets the timestamp of the most recent - * instance of a failover to the secondary location. Only the most recent - * timestamp is retained. This element is not returned if there has never - * been a failover instance. Only available if the accountType is StandardGRS - * or StandardRAGRS. - * @member {string} [secondaryLocation] Gets the location of the geo - * replicated secondary for the storage account. Only available if the - * accountType is StandardGRS or StandardRAGRS. - * @member {string} [statusOfSecondary] Gets the status indicating whether - * the secondary location of the storage account is available or unavailable. - * Only available if the accountType is StandardGRS or StandardRAGRS. - * Possible values include: 'Available', 'Unavailable' - * @member {date} [creationTime] Gets the creation date and time of the - * storage account in UTC. - * @member {object} [customDomain] Gets the user assigned custom domain - * assigned to this storage account. - * @member {string} [customDomain.name] Gets or sets the custom domain name. - * Name is the CNAME source. - * @member {boolean} [customDomain.useSubDomain] Indicates whether indirect - * CName validation is enabled. Default value is false. This should only be - * set on updates - * @member {object} [secondaryEndpoints] Gets the URLs that are used to - * perform a retrieval of a public blob, queue or table object from the - * secondary location of the storage account. Only available if the - * accountType is StandardRAGRS. - * @member {string} [secondaryEndpoints.blob] Gets the blob endpoint. - * @member {string} [secondaryEndpoints.queue] Gets the queue endpoint. - * @member {string} [secondaryEndpoints.table] Gets the table endpoint. - * @member {string} [secondaryEndpoints.file] Gets the file endpoint. - */ - constructor() { - super(); - } - - /** - * Defines the metadata of StorageAccount - * - * @returns {object} metadata of StorageAccount - * - */ - mapper() { - return { - required: false, - serializedName: 'StorageAccount', - type: { - name: 'Composite', - className: 'StorageAccount', - modelProperties: { - id: { - required: false, - readOnly: true, - serializedName: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - readOnly: true, - serializedName: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - readOnly: true, - serializedName: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serializedName: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serializedName: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serializedName: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - provisioningState: { - required: false, - serializedName: 'properties.provisioningState', - type: { - name: 'Enum', - allowedValues: [ 'Creating', 'ResolvingDNS', 'Succeeded' ] - } - }, - accountType: { - required: false, - serializedName: 'properties.accountType', - type: { - name: 'Enum', - allowedValues: [ 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' ] - } - }, - primaryEndpoints: { - required: false, - serializedName: 'properties.primaryEndpoints', - type: { - name: 'Composite', - className: 'Endpoints' - } - }, - primaryLocation: { - required: false, - serializedName: 'properties.primaryLocation', - type: { - name: 'String' - } - }, - statusOfPrimary: { - required: false, - serializedName: 'properties.statusOfPrimary', - type: { - name: 'Enum', - allowedValues: [ 'Available', 'Unavailable' ] - } - }, - lastGeoFailoverTime: { - required: false, - serializedName: 'properties.lastGeoFailoverTime', - type: { - name: 'DateTime' - } - }, - secondaryLocation: { - required: false, - serializedName: 'properties.secondaryLocation', - type: { - name: 'String' - } - }, - statusOfSecondary: { - required: false, - serializedName: 'properties.statusOfSecondary', - type: { - name: 'Enum', - allowedValues: [ 'Available', 'Unavailable' ] - } - }, - creationTime: { - required: false, - serializedName: 'properties.creationTime', - type: { - name: 'DateTime' - } - }, - customDomain: { - required: false, - serializedName: 'properties.customDomain', - type: { - name: 'Composite', - className: 'CustomDomain' - } - }, - secondaryEndpoints: { - required: false, - serializedName: 'properties.secondaryEndpoints', - type: { - name: 'Composite', - className: 'Endpoints' - } - } - } - } - }; - } -} - -module.exports = StorageAccount; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/storageAccountCheckNameAvailabilityParameters.js b/Samples/2a-validation/NodeJS/models/storageAccountCheckNameAvailabilityParameters.js index 82ec87130..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/storageAccountCheckNameAvailabilityParameters.js +++ b/Samples/2a-validation/NodeJS/models/storageAccountCheckNameAvailabilityParameters.js @@ -1,57 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * Class representing a StorageAccountCheckNameAvailabilityParameters. - */ -class StorageAccountCheckNameAvailabilityParameters { - /** - * Create a StorageAccountCheckNameAvailabilityParameters. - * @member {string} name - * @member {string} [type] Default value: 'Microsoft.Storage/storageAccounts' - * . - */ - constructor() { - } - - /** - * Defines the metadata of StorageAccountCheckNameAvailabilityParameters - * - * @returns {object} metadata of StorageAccountCheckNameAvailabilityParameters - * - */ - mapper() { - return { - required: false, - serializedName: 'StorageAccountCheckNameAvailabilityParameters', - type: { - name: 'Composite', - className: 'StorageAccountCheckNameAvailabilityParameters', - modelProperties: { - name: { - required: true, - serializedName: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - serializedName: 'type', - defaultValue: 'Microsoft.Storage/storageAccounts', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = StorageAccountCheckNameAvailabilityParameters; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/storageAccountCreateParameters.js b/Samples/2a-validation/NodeJS/models/storageAccountCreateParameters.js index cd54ec9de..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/storageAccountCreateParameters.js +++ b/Samples/2a-validation/NodeJS/models/storageAccountCreateParameters.js @@ -1,78 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const models = require('./index'); - -/** - * The parameters to provide for the account. - * - * @extends models['BaseResource'] - */ -class StorageAccountCreateParameters extends models['BaseResource'] { - /** - * Create a StorageAccountCreateParameters. - * @member {string} location Resource location - * @member {object} [tags] Resource tags - * @member {string} accountType Gets or sets the account type. Possible - * values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - */ - constructor() { - super(); - } - - /** - * Defines the metadata of StorageAccountCreateParameters - * - * @returns {object} metadata of StorageAccountCreateParameters - * - */ - mapper() { - return { - required: false, - serializedName: 'StorageAccountCreateParameters', - type: { - name: 'Composite', - className: 'StorageAccountCreateParameters', - modelProperties: { - location: { - required: true, - serializedName: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serializedName: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serializedName: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - accountType: { - required: true, - serializedName: 'properties.accountType', - type: { - name: 'Enum', - allowedValues: [ 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' ] - } - } - } - } - }; - } -} - -module.exports = StorageAccountCreateParameters; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/storageAccountKeys.js b/Samples/2a-validation/NodeJS/models/storageAccountKeys.js index 97841eaf6..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/storageAccountKeys.js +++ b/Samples/2a-validation/NodeJS/models/storageAccountKeys.js @@ -1,56 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * The access keys for the storage account. - * - */ -class StorageAccountKeys { - /** - * Create a StorageAccountKeys. - * @member {string} [key1] Gets the value of key 1. - * @member {string} [key2] Gets the value of key 2. - */ - constructor() { - } - - /** - * Defines the metadata of StorageAccountKeys - * - * @returns {object} metadata of StorageAccountKeys - * - */ - mapper() { - return { - required: false, - serializedName: 'StorageAccountKeys', - type: { - name: 'Composite', - className: 'StorageAccountKeys', - modelProperties: { - key1: { - required: false, - serializedName: 'key1', - type: { - name: 'String' - } - }, - key2: { - required: false, - serializedName: 'key2', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = StorageAccountKeys; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/storageAccountListResult.js b/Samples/2a-validation/NodeJS/models/storageAccountListResult.js index e17fb6f0f..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/storageAccountListResult.js +++ b/Samples/2a-validation/NodeJS/models/storageAccountListResult.js @@ -1,55 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * The list storage accounts operation response. - */ -class StorageAccountListResult extends Array { - /** - * Create a StorageAccountListResult. - */ - constructor() { - super(); - } - - /** - * Defines the metadata of StorageAccountListResult - * - * @returns {object} metadata of StorageAccountListResult - * - */ - mapper() { - return { - required: false, - serializedName: 'StorageAccountListResult', - type: { - name: 'Composite', - className: 'StorageAccountListResult', - modelProperties: { - value: { - required: false, - serializedName: '', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'StorageAccountElementType', - type: { - name: 'Composite', - className: 'StorageAccount' - } - } - } - } - } - } - }; - } -} - -module.exports = StorageAccountListResult; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/storageAccountRegenerateKeyParameters.js b/Samples/2a-validation/NodeJS/models/storageAccountRegenerateKeyParameters.js index 49d13d8ee..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/storageAccountRegenerateKeyParameters.js +++ b/Samples/2a-validation/NodeJS/models/storageAccountRegenerateKeyParameters.js @@ -1,47 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * Class representing a StorageAccountRegenerateKeyParameters. - */ -class StorageAccountRegenerateKeyParameters { - /** - * Create a StorageAccountRegenerateKeyParameters. - * @member {string} keyName - */ - constructor() { - } - - /** - * Defines the metadata of StorageAccountRegenerateKeyParameters - * - * @returns {object} metadata of StorageAccountRegenerateKeyParameters - * - */ - mapper() { - return { - required: false, - serializedName: 'StorageAccountRegenerateKeyParameters', - type: { - name: 'Composite', - className: 'StorageAccountRegenerateKeyParameters', - modelProperties: { - keyName: { - required: true, - serializedName: 'keyName', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = StorageAccountRegenerateKeyParameters; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/storageAccountUpdateParameters.js b/Samples/2a-validation/NodeJS/models/storageAccountUpdateParameters.js index 8c56d2e7c..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/storageAccountUpdateParameters.js +++ b/Samples/2a-validation/NodeJS/models/storageAccountUpdateParameters.js @@ -1,89 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const models = require('./index'); - -/** - * The parameters to update on the account. - * - * @extends models['BaseResource'] - */ -class StorageAccountUpdateParameters extends models['BaseResource'] { - /** - * Create a StorageAccountUpdateParameters. - * @member {object} [tags] Resource tags - * @member {string} [accountType] Gets or sets the account type. Note that - * StandardZRS and PremiumLRS accounts cannot be changed to other account - * types, and other account types cannot be changed to StandardZRS or - * PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', - * 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - * @member {object} [customDomain] User domain assigned to the storage - * account. Name is the CNAME source. Only one custom domain is supported per - * storage account at this time. To clear the existing custom domain, use an - * empty string for the custom domain name property. - * @member {string} [customDomain.name] Gets or sets the custom domain name. - * Name is the CNAME source. - * @member {boolean} [customDomain.useSubDomain] Indicates whether indirect - * CName validation is enabled. Default value is false. This should only be - * set on updates - */ - constructor() { - super(); - } - - /** - * Defines the metadata of StorageAccountUpdateParameters - * - * @returns {object} metadata of StorageAccountUpdateParameters - * - */ - mapper() { - return { - required: false, - serializedName: 'StorageAccountUpdateParameters', - type: { - name: 'Composite', - className: 'StorageAccountUpdateParameters', - modelProperties: { - tags: { - required: false, - serializedName: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serializedName: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - accountType: { - required: false, - serializedName: 'properties.accountType', - type: { - name: 'Enum', - allowedValues: [ 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' ] - } - }, - customDomain: { - required: false, - serializedName: 'properties.customDomain', - type: { - name: 'Composite', - className: 'CustomDomain' - } - } - } - } - }; - } -} - -module.exports = StorageAccountUpdateParameters; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/usage.js b/Samples/2a-validation/NodeJS/models/usage.js index ed03baecf..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/usage.js +++ b/Samples/2a-validation/NodeJS/models/usage.js @@ -1,83 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const models = require('./index'); - -/** - * Describes Storage Resource Usage. - * - */ -class Usage { - /** - * Create a Usage. - * @member {string} unit Gets the unit of measurement. Possible values - * include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - * 'BytesPerSecond' - * @member {number} currentValue Gets the current count of the allocated - * resources in the subscription. - * @member {number} limit Gets the maximum count of the resources that can be - * allocated in the subscription. - * @member {object} name Gets the name of the type of usage. - * @member {string} [name.value] Gets a string describing the resource name. - * @member {string} [name.localizedValue] Gets a localized string describing - * the resource name. - */ - constructor() { - } - - /** - * Defines the metadata of Usage - * - * @returns {object} metadata of Usage - * - */ - mapper() { - return { - required: false, - serializedName: 'Usage', - type: { - name: 'Composite', - className: 'Usage', - modelProperties: { - unit: { - required: true, - serializedName: 'unit', - type: { - name: 'Enum', - allowedValues: [ 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' ] - } - }, - currentValue: { - required: true, - serializedName: 'currentValue', - type: { - name: 'Number' - } - }, - limit: { - required: true, - serializedName: 'limit', - type: { - name: 'Number' - } - }, - name: { - required: true, - serializedName: 'name', - type: { - name: 'Composite', - className: 'UsageName' - } - } - } - } - }; - } -} - -module.exports = Usage; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/usageListResult.js b/Samples/2a-validation/NodeJS/models/usageListResult.js index dbdb03d9a..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/usageListResult.js +++ b/Samples/2a-validation/NodeJS/models/usageListResult.js @@ -1,55 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * The List Usages operation response. - */ -class UsageListResult extends Array { - /** - * Create a UsageListResult. - */ - constructor() { - super(); - } - - /** - * Defines the metadata of UsageListResult - * - * @returns {object} metadata of UsageListResult - * - */ - mapper() { - return { - required: false, - serializedName: 'UsageListResult', - type: { - name: 'Composite', - className: 'UsageListResult', - modelProperties: { - value: { - required: false, - serializedName: '', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'UsageElementType', - type: { - name: 'Composite', - className: 'Usage' - } - } - } - } - } - } - }; - } -} - -module.exports = UsageListResult; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/models/usageName.js b/Samples/2a-validation/NodeJS/models/usageName.js index e66902a53..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/models/usageName.js +++ b/Samples/2a-validation/NodeJS/models/usageName.js @@ -1,57 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -/** - * The Usage Names. - * - */ -class UsageName { - /** - * Create a UsageName. - * @member {string} [value] Gets a string describing the resource name. - * @member {string} [localizedValue] Gets a localized string describing the - * resource name. - */ - constructor() { - } - - /** - * Defines the metadata of UsageName - * - * @returns {object} metadata of UsageName - * - */ - mapper() { - return { - required: false, - serializedName: 'UsageName', - type: { - name: 'Composite', - className: 'UsageName', - modelProperties: { - value: { - required: false, - serializedName: 'value', - type: { - name: 'String' - } - }, - localizedValue: { - required: false, - serializedName: 'localizedValue', - type: { - name: 'String' - } - } - } - } - }; - } -} - -module.exports = UsageName; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/operations/index.js b/Samples/2a-validation/NodeJS/operations/index.js index d35980ac5..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/operations/index.js +++ b/Samples/2a-validation/NodeJS/operations/index.js @@ -1,14 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -exports.StorageAccounts = require('./storageAccounts'); -exports.UsageOperations = require('./usageOperations'); +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/operations/storageAccounts.js b/Samples/2a-validation/NodeJS/operations/storageAccounts.js index 5b8f86f37..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/operations/storageAccounts.js +++ b/Samples/2a-validation/NodeJS/operations/storageAccounts.js @@ -1,2646 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const msRest = require('ms-rest'); -const msRestAzure = require('ms-rest-azure'); -const WebResource = msRest.WebResource; - -/** - * Checks that account name is valid and is not in use. - * - * @param {object} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {string} accountName.name - * - * @param {string} [accountName.type] - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link CheckNameAvailabilityResult} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _checkNameAvailability(accountName, 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 (accountName === null || accountName === undefined) { - throw new Error('accountName cannot be null or undefined.'); - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'; - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (accountName !== null && accountName !== undefined) { - let requestModelMapper = new client.models['StorageAccountCheckNameAvailabilityParameters']().mapper(); - requestModel = client.serialize(requestModelMapper, accountName, 'accountName'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(accountName, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['CheckNameAvailabilityResult']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - - -/** - * Asynchronously creates a new storage account with the specified parameters. - * Existing accounts cannot be updated with this API and should instead use the - * Update Storage Account API. If an account is already created and subsequent - * PUT request is issued with exact same set of properties, then HTTP 200 would - * be returned. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to provide for the created - * account. - * - * @param {string} parameters.location Resource location - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} parameters.accountType Gets or sets the account type. - * Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _create(resourceGroupName, accountName, parameters, 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.'); - } - - // Send request - this.beginCreate(resourceGroupName, accountName, parameters, options, (err, parsedResult, httpRequest, response) => { - if (err) return callback(err); - - let initialResult = new msRest.HttpOperationResponse(); - initialResult.request = httpRequest; - initialResult.response = response; - initialResult.body = response.body; - client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { - if (err) return callback(err); - - // Create Result - let result = null; - - httpRequest = pollingResult.request; - response = pollingResult.response; - let responseBody = pollingResult.body; - if (responseBody === '') responseBody = null; - - // Deserialize Response - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccount']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - - return callback(null, result, httpRequest, response); - }); - }); -} - -/** - * Deletes a storage account in Microsoft Azure. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _deleteMethod(resourceGroupName, accountName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - 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 (accountName !== null && accountName !== undefined) { - if (accountName.length > 24) - { - throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24'); - } - if (accountName.length < 3) - { - throw new Error('"accountName" should satisfy the constraint - "MinLength": 3'); - } - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'DELETE'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 204) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Returns the properties for the specified storage account including but not - * limited to name, account type, location, and account status. The ListKeys - * operation should be used to retrieve storage keys. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _getProperties(resourceGroupName, accountName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - 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 (accountName !== null && accountName !== undefined) { - if (accountName.length > 24) - { - throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24'); - } - if (accountName.length < 3) - { - throw new Error('"accountName" should satisfy the constraint - "MinLength": 3'); - } - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccount']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Updates the account type or tags for a storage account. It can also be used - * to add a custom domain (note that custom domains cannot be added via the - * Create operation). Only one custom domain is supported per storage account. - * In order to replace a custom domain, the old value must be cleared before a - * new value may be set. To clear a custom domain, simply update the custom - * domain with empty string. Then call update again with the new cutsom domain - * name. The update API can only be used to update one of tags, accountType, or - * customDomain per call. To update multiple of these properties, call the API - * multiple times with one change per call. This call does not change the - * storage keys for the account. If you want to change storage account keys, - * use the RegenerateKey operation. The location and name of the storage - * account cannot be changed after creation. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to update on the account. Note - * that only one property can be changed at a time using this API. - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} [parameters.accountType] Gets or sets the account type. Note - * that StandardZRS and PremiumLRS accounts cannot be changed to other account - * types, and other account types cannot be changed to StandardZRS or - * PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', - * 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [parameters.customDomain] User domain assigned to the - * storage account. Name is the CNAME source. Only one custom domain is - * supported per storage account at this time. To clear the existing custom - * domain, use an empty string for the custom domain name property. - * - * @param {string} parameters.customDomain.name Gets or sets the custom domain - * name. Name is the CNAME source. - * - * @param {boolean} [parameters.customDomain.useSubDomain] Indicates whether - * indirect CName validation is enabled. Default value is false. This should - * only be set on updates - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _update(resourceGroupName, accountName, parameters, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - 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 (accountName !== null && accountName !== undefined) { - if (accountName.length > 24) - { - throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24'); - } - if (accountName.length < 3) - { - throw new Error('"accountName" should satisfy the constraint - "MinLength": 3'); - } - } - if (parameters === null || parameters === undefined) { - throw new Error('parameters cannot be null or undefined.'); - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'PATCH'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (parameters !== null && parameters !== undefined) { - let requestModelMapper = new client.models['StorageAccountUpdateParameters']().mapper(); - requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccount']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Lists the access keys for the specified storage account. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} accountName The name of the storage account. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountKeys} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _listKeys(resourceGroupName, accountName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - 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 (accountName !== null && accountName !== undefined) { - if (accountName.length > 24) - { - throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24'); - } - if (accountName.length < 3) - { - throw new Error('"accountName" should satisfy the constraint - "MinLength": 3'); - } - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccountKeys']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Lists all the storage accounts available under the subscription. Note that - * storage keys are not returned; use the ListKeys operation for this. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountListResult} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _list(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 (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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'; - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccountListResult']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Lists all the storage accounts available under the given resource group. - * Note that storage keys are not returned; use the ListKeys operation for - * this. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountListResult} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _listByResourceGroup(resourceGroupName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccountListResult']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Regenerates the access keys for the specified storage account. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} regenerateKeyParameter Specifies name of the key which - * should be regenerated. key1 or key2 for the default keys - * - * @param {string} regenerateKeyParameter.keyName - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountKeys} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _regenerateKey(resourceGroupName, accountName, regenerateKeyParameter, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - 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 (accountName !== null && accountName !== undefined) { - if (accountName.length > 24) - { - throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24'); - } - if (accountName.length < 3) - { - throw new Error('"accountName" should satisfy the constraint - "MinLength": 3'); - } - } - if (regenerateKeyParameter === null || regenerateKeyParameter === undefined) { - throw new Error('regenerateKeyParameter cannot be null or undefined.'); - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (regenerateKeyParameter !== null && regenerateKeyParameter !== undefined) { - let requestModelMapper = new client.models['StorageAccountRegenerateKeyParameters']().mapper(); - requestModel = client.serialize(requestModelMapper, regenerateKeyParameter, 'regenerateKeyParameter'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(regenerateKeyParameter, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccountKeys']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * Asynchronously creates a new storage account with the specified parameters. - * Existing accounts cannot be updated with this API and should instead use the - * Update Storage Account API. If an account is already created and subsequent - * PUT request is issued with exact same set of properties, then HTTP 200 would - * be returned. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to provide for the created - * account. - * - * @param {string} parameters.location Resource location - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} parameters.accountType Gets or sets the account type. - * Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _beginCreate(resourceGroupName, accountName, parameters, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - 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 (accountName !== null && accountName !== undefined) { - if (accountName.length > 24) - { - throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24'); - } - if (accountName.length < 3) - { - throw new Error('"accountName" should satisfy the constraint - "MinLength": 3'); - } - } - if (parameters === null || parameters === undefined) { - throw new Error('parameters cannot be null or undefined.'); - } - 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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'PUT'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (parameters !== null && parameters !== undefined) { - let requestModelMapper = new client.models['StorageAccountCreateParameters']().mapper(); - requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 202) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['StorageAccount']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a StorageAccounts. */ -class StorageAccounts { - /** - * Create a StorageAccounts. - * @param {StorageManagementClient} client Reference to the service client. - */ - constructor(client) { - this.client = client; - this._checkNameAvailability = _checkNameAvailability; - this._create = _create; - this._deleteMethod = _deleteMethod; - this._getProperties = _getProperties; - this._update = _update; - this._listKeys = _listKeys; - this._list = _list; - this._listByResourceGroup = _listByResourceGroup; - this._regenerateKey = _regenerateKey; - this._beginCreate = _beginCreate; - } - - /** - * Checks that account name is valid and is not in use. - * - * @param {object} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {string} accountName.name - * - * @param {string} [accountName.type] - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - checkNameAvailabilityWithHttpOperationResponse(accountName, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._checkNameAvailability(accountName, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param {object} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {string} accountName.name - * - * @param {string} [accountName.type] - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {CheckNameAvailabilityResult} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link CheckNameAvailabilityResult} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - checkNameAvailability(accountName, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._checkNameAvailability(accountName, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._checkNameAvailability(accountName, options, optionalCallback); - } - } - - /** - * Asynchronously creates a new storage account with the specified parameters. - * Existing accounts cannot be updated with this API and should instead use the - * Update Storage Account API. If an account is already created and subsequent - * PUT request is issued with exact same set of properties, then HTTP 200 would - * be returned. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to provide for the created - * account. - * - * @param {string} parameters.location Resource location - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} parameters.accountType Gets or sets the account type. - * Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - createWithHttpOperationResponse(resourceGroupName, accountName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._create(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. - * Existing accounts cannot be updated with this API and should instead use the - * Update Storage Account API. If an account is already created and subsequent - * PUT request is issued with exact same set of properties, then HTTP 200 would - * be returned. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to provide for the created - * account. - * - * @param {string} parameters.location Resource location - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} parameters.accountType Gets or sets the account type. - * Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccount} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - create(resourceGroupName, accountName, parameters, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._create(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._create(resourceGroupName, accountName, parameters, options, optionalCallback); - } - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - deleteMethodWithHttpOperationResponse(resourceGroupName, accountName, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._deleteMethod(resourceGroupName, accountName, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - deleteMethod(resourceGroupName, accountName, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._deleteMethod(resourceGroupName, accountName, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._deleteMethod(resourceGroupName, accountName, options, optionalCallback); - } - } - - /** - * Returns the properties for the specified storage account including but not - * limited to name, account type, location, and account status. The ListKeys - * operation should be used to retrieve storage keys. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - getPropertiesWithHttpOperationResponse(resourceGroupName, accountName, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._getProperties(resourceGroupName, accountName, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Returns the properties for the specified storage account including but not - * limited to name, account type, location, and account status. The ListKeys - * operation should be used to retrieve storage keys. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccount} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - getProperties(resourceGroupName, accountName, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._getProperties(resourceGroupName, accountName, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._getProperties(resourceGroupName, accountName, options, optionalCallback); - } - } - - /** - * Updates the account type or tags for a storage account. It can also be used - * to add a custom domain (note that custom domains cannot be added via the - * Create operation). Only one custom domain is supported per storage account. - * In order to replace a custom domain, the old value must be cleared before a - * new value may be set. To clear a custom domain, simply update the custom - * domain with empty string. Then call update again with the new cutsom domain - * name. The update API can only be used to update one of tags, accountType, or - * customDomain per call. To update multiple of these properties, call the API - * multiple times with one change per call. This call does not change the - * storage keys for the account. If you want to change storage account keys, - * use the RegenerateKey operation. The location and name of the storage - * account cannot be changed after creation. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to update on the account. Note - * that only one property can be changed at a time using this API. - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} [parameters.accountType] Gets or sets the account type. Note - * that StandardZRS and PremiumLRS accounts cannot be changed to other account - * types, and other account types cannot be changed to StandardZRS or - * PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', - * 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [parameters.customDomain] User domain assigned to the - * storage account. Name is the CNAME source. Only one custom domain is - * supported per storage account at this time. To clear the existing custom - * domain, use an empty string for the custom domain name property. - * - * @param {string} parameters.customDomain.name Gets or sets the custom domain - * name. Name is the CNAME source. - * - * @param {boolean} [parameters.customDomain.useSubDomain] Indicates whether - * indirect CName validation is enabled. Default value is false. This should - * only be set on updates - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - updateWithHttpOperationResponse(resourceGroupName, accountName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._update(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Updates the account type or tags for a storage account. It can also be used - * to add a custom domain (note that custom domains cannot be added via the - * Create operation). Only one custom domain is supported per storage account. - * In order to replace a custom domain, the old value must be cleared before a - * new value may be set. To clear a custom domain, simply update the custom - * domain with empty string. Then call update again with the new cutsom domain - * name. The update API can only be used to update one of tags, accountType, or - * customDomain per call. To update multiple of these properties, call the API - * multiple times with one change per call. This call does not change the - * storage keys for the account. If you want to change storage account keys, - * use the RegenerateKey operation. The location and name of the storage - * account cannot be changed after creation. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to update on the account. Note - * that only one property can be changed at a time using this API. - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} [parameters.accountType] Gets or sets the account type. Note - * that StandardZRS and PremiumLRS accounts cannot be changed to other account - * types, and other account types cannot be changed to StandardZRS or - * PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', - * 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [parameters.customDomain] User domain assigned to the - * storage account. Name is the CNAME source. Only one custom domain is - * supported per storage account at this time. To clear the existing custom - * domain, use an empty string for the custom domain name property. - * - * @param {string} parameters.customDomain.name Gets or sets the custom domain - * name. Name is the CNAME source. - * - * @param {boolean} [parameters.customDomain.useSubDomain] Indicates whether - * indirect CName validation is enabled. Default value is false. This should - * only be set on updates - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccount} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - update(resourceGroupName, accountName, parameters, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._update(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._update(resourceGroupName, accountName, parameters, options, optionalCallback); - } - } - - /** - * Lists the access keys for the specified storage account. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} accountName The name of the storage account. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - listKeysWithHttpOperationResponse(resourceGroupName, accountName, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._listKeys(resourceGroupName, accountName, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} accountName The name of the storage account. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccountKeys} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountKeys} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - listKeys(resourceGroupName, accountName, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._listKeys(resourceGroupName, accountName, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._listKeys(resourceGroupName, accountName, options, optionalCallback); - } - } - - /** - * Lists all the storage accounts available under the subscription. Note that - * storage keys are not returned; use the ListKeys operation for this. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - listWithHttpOperationResponse(options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Lists all the storage accounts available under the subscription. Note that - * storage keys are not returned; use the ListKeys operation for this. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccountListResult} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountListResult} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - list(options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._list(options, optionalCallback); - } - } - - /** - * Lists all the storage accounts available under the given resource group. - * Note that storage keys are not returned; use the ListKeys operation for - * this. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Lists all the storage accounts available under the given resource group. - * Note that storage keys are not returned; use the ListKeys operation for - * this. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccountListResult} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountListResult} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - listByResourceGroup(resourceGroupName, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._listByResourceGroup(resourceGroupName, options, optionalCallback); - } - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} regenerateKeyParameter Specifies name of the key which - * should be regenerated. key1 or key2 for the default keys - * - * @param {string} regenerateKeyParameter.keyName - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - regenerateKeyWithHttpOperationResponse(resourceGroupName, accountName, regenerateKeyParameter, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._regenerateKey(resourceGroupName, accountName, regenerateKeyParameter, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} regenerateKeyParameter Specifies name of the key which - * should be regenerated. key1 or key2 for the default keys - * - * @param {string} regenerateKeyParameter.keyName - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccountKeys} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccountKeys} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - regenerateKey(resourceGroupName, accountName, regenerateKeyParameter, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._regenerateKey(resourceGroupName, accountName, regenerateKeyParameter, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._regenerateKey(resourceGroupName, accountName, regenerateKeyParameter, options, optionalCallback); - } - } - - /** - * Asynchronously creates a new storage account with the specified parameters. - * Existing accounts cannot be updated with this API and should instead use the - * Update Storage Account API. If an account is already created and subsequent - * PUT request is issued with exact same set of properties, then HTTP 200 would - * be returned. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to provide for the created - * account. - * - * @param {string} parameters.location Resource location - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} parameters.accountType Gets or sets the account type. - * Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - beginCreateWithHttpOperationResponse(resourceGroupName, accountName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._beginCreate(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. - * Existing accounts cannot be updated with this API and should instead use the - * Update Storage Account API. If an account is already created and subsequent - * PUT request is issued with exact same set of properties, then HTTP 200 would - * be returned. - * - * @param {string} resourceGroupName The name of the resource group within the - * user's subscription. - * - * @param {string} accountName The name of the storage account within the - * specified resource group. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - * - * @param {object} parameters The parameters to provide for the created - * account. - * - * @param {string} parameters.location Resource location - * - * @param {object} [parameters.tags] Resource tags - * - * @param {string} parameters.accountType Gets or sets the account type. - * Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {StorageAccount} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link StorageAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - beginCreate(resourceGroupName, accountName, parameters, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._beginCreate(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._beginCreate(resourceGroupName, accountName, parameters, options, optionalCallback); - } - } - -} - -module.exports = StorageAccounts; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/operations/usageOperations.js b/Samples/2a-validation/NodeJS/operations/usageOperations.js index 3feee0369..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/operations/usageOperations.js +++ b/Samples/2a-validation/NodeJS/operations/usageOperations.js @@ -1,240 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const msRest = require('ms-rest'); -const msRestAzure = require('ms-rest-azure'); -const WebResource = msRest.WebResource; - -/** - * Gets the current usage count and the limit for the resources under the - * subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link UsageListResult} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _list(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 (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.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 - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'; - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; - if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; - if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['CloudError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['UsageListResult']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a UsageOperations. */ -class UsageOperations { - /** - * Create a UsageOperations. - * @param {StorageManagementClient} client Reference to the service client. - */ - constructor(client) { - this.client = client; - this._list = _list; - } - - /** - * Gets the current usage count and the limit for the resources under the - * subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - listWithHttpOperationResponse(options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Gets the current usage count and the limit for the resources under the - * subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {UsageListResult} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link UsageListResult} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - list(options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._list(options, optionalCallback); - } - } - -} - -module.exports = UsageOperations; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/NodeJS/storageManagementClient.js b/Samples/2a-validation/NodeJS/storageManagementClient.js index df610abfd..9d6cafc2c 100644 --- a/Samples/2a-validation/NodeJS/storageManagementClient.js +++ b/Samples/2a-validation/NodeJS/storageManagementClient.js @@ -1,79 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -const msRest = require('ms-rest'); -const msRestAzure = require('ms-rest-azure'); -const ServiceClient = msRestAzure.AzureServiceClient; - -const models = require('./models'); -const operations = require('./operations'); - - -/** Class representing a StorageManagementClient. */ -class StorageManagementClient extends ServiceClient { - /** - * Create a StorageManagementClient. - * @param {credentials} credentials - Credentials needed for the client to connect to Azure. - * @param {string} subscriptionId - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - * @param {string} [baseUri] - The base URI of the service. - * @param {object} [options] - The parameter options - * @param {Array} [options.filters] - Filters to be added to the request pipeline - * @param {object} [options.requestOptions] - Options for the underlying request object - * {@link https://github.com/request/request#requestoptions-callback Options doc} - * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy - * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. - * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - */ - constructor(credentials, subscriptionId, baseUri, options) { - if (credentials === null || credentials === undefined) { - throw new Error('\'credentials\' cannot be null.'); - } - if (subscriptionId === null || subscriptionId === undefined) { - throw new Error('\'subscriptionId\' cannot be null.'); - } - - if (!options) options = {}; - - super(credentials, options); - - this.apiVersion = '2015-06-15'; - this.acceptLanguage = 'en-US'; - this.longRunningOperationRetryTimeout = 30; - this.generateClientRequestId = true; - this.baseUri = baseUri; - if (!this.baseUri) { - this.baseUri = 'https://management.azure.com'; - } - this.credentials = credentials; - this.subscriptionId = subscriptionId; - - let packageInfo = this.getPackageJsonInfo(__dirname); - this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); - if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { - this.acceptLanguage = options.acceptLanguage; - } - if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { - this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; - } - if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { - this.generateClientRequestId = options.generateClientRequestId; - } - this.storageAccounts = new operations.StorageAccounts(this); - this.usageOperations = new operations.UsageOperations(this); - this.models = models; - msRest.addSerializationMixin(this); - } - -} - -module.exports = StorageManagementClient; +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/setup.py b/Samples/2a-validation/Python/setup.py index d286af1a9..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/setup.py +++ b/Samples/2a-validation/Python/setup.py @@ -1,36 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# coding: utf-8 - -from setuptools import setup, find_packages - -NAME = "storagemanagementclient" -VERSION = "2015-06-15" - -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools - -REQUIRES = ["msrestazure>=0.4.7"] - -setup( - name=NAME, - version=VERSION, - description="StorageManagementClient", - author_email="", - url="", - keywords=["Swagger", "StorageManagementClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - The Storage Management Client. - """ -) +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/__init__.py b/Samples/2a-validation/Python/storage/__init__.py index abf1139d8..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/__init__.py +++ b/Samples/2a-validation/Python/storage/__init__.py @@ -1,14 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .storage_management_client import StorageManagementClient -from .version import VERSION - -__all__ = ['StorageManagementClient'] - -__version__ = VERSION - +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/__init__.py b/Samples/2a-validation/Python/storage/models/__init__.py index 8fdfe8764..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/__init__.py +++ b/Samples/2a-validation/Python/storage/models/__init__.py @@ -1,50 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .storage_account_check_name_availability_parameters import StorageAccountCheckNameAvailabilityParameters -from .check_name_availability_result import CheckNameAvailabilityResult -from .storage_account_create_parameters import StorageAccountCreateParameters -from .endpoints import Endpoints -from .custom_domain import CustomDomain -from .storage_account import StorageAccount -from .storage_account_keys import StorageAccountKeys -from .storage_account_update_parameters import StorageAccountUpdateParameters -from .storage_account_regenerate_key_parameters import StorageAccountRegenerateKeyParameters -from .usage_name import UsageName -from .usage import Usage -from .resource import Resource -from .storage_account_paged import StorageAccountPaged -from .usage_paged import UsagePaged -from .storage_management_client_enums import ( - Reason, - AccountType, - ProvisioningState, - AccountStatus, - UsageUnit, -) - -__all__ = [ - 'StorageAccountCheckNameAvailabilityParameters', - 'CheckNameAvailabilityResult', - 'StorageAccountCreateParameters', - 'Endpoints', - 'CustomDomain', - 'StorageAccount', - 'StorageAccountKeys', - 'StorageAccountUpdateParameters', - 'StorageAccountRegenerateKeyParameters', - 'UsageName', - 'Usage', - 'Resource', - 'StorageAccountPaged', - 'UsagePaged', - 'Reason', - 'AccountType', - 'ProvisioningState', - 'AccountStatus', - 'UsageUnit', -] +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/check_name_availability_result.py b/Samples/2a-validation/Python/storage/models/check_name_availability_result.py index 807d92e0b..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/check_name_availability_result.py +++ b/Samples/2a-validation/Python/storage/models/check_name_availability_result.py @@ -1,36 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class CheckNameAvailabilityResult(Model): - """The CheckNameAvailability operation response. - - :param name_available: Gets a boolean value that indicates whether the - name is available for you to use. If true, the name is available. If - false, the name has already been taken or invalid and cannot be used. - :type name_available: bool - :param reason: Gets the reason that a storage account name could not be - used. The Reason element is only returned if NameAvailable is false. - Possible values include: 'AccountNameInvalid', 'AlreadyExists' - :type reason: str or :class:`Reason ` - :param message: Gets an error message explaining the Reason value in more - detail. - :type message: str - """ - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'Reason'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__(self, name_available=None, reason=None, message=None): - self.name_available = name_available - self.reason = reason - self.message = message +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/custom_domain.py b/Samples/2a-validation/Python/storage/models/custom_domain.py index 41dba58ea..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/custom_domain.py +++ b/Samples/2a-validation/Python/storage/models/custom_domain.py @@ -1,34 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class CustomDomain(Model): - """The custom domain assigned to this storage account. This can be set via - Update. - - :param name: Gets or sets the custom domain name. Name is the CNAME - source. - :type name: str - :param use_sub_domain: Indicates whether indirect CName validation is - enabled. Default value is false. This should only be set on updates - :type use_sub_domain: bool - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain': {'key': 'useSubDomain', 'type': 'bool'}, - } - - def __init__(self, name, use_sub_domain=None): - self.name = name - self.use_sub_domain = use_sub_domain +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/endpoints.py b/Samples/2a-validation/Python/storage/models/endpoints.py index a7e9dbe1e..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/endpoints.py +++ b/Samples/2a-validation/Python/storage/models/endpoints.py @@ -1,36 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class Endpoints(Model): - """The URIs that are used to perform a retrieval of a public blob, queue or - table object. - - :param blob: Gets the blob endpoint. - :type blob: str - :param queue: Gets the queue endpoint. - :type queue: str - :param table: Gets the table endpoint. - :type table: str - :param file: Gets the file endpoint. - :type file: str - """ - - _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - } - - def __init__(self, blob=None, queue=None, table=None, file=None): - self.blob = blob - self.queue = queue - self.table = table - self.file = file +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/resource.py b/Samples/2a-validation/Python/storage/models/resource.py index 141e8eb13..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/resource.py +++ b/Samples/2a-validation/Python/storage/models/resource.py @@ -1,48 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class Resource(Model): - """Resource. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Resource Id - :vartype id: str - :ivar name: Resource name - :vartype name: str - :ivar type: Resource type - :vartype type: str - :param location: Resource location - :type location: str - :param tags: Resource tags - :type tags: dict - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__(self, location=None, tags=None): - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_account.py b/Samples/2a-validation/Python/storage/models/storage_account.py index f95c9068c..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_account.py +++ b/Samples/2a-validation/Python/storage/models/storage_account.py @@ -1,115 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .resource import Resource - - -class StorageAccount(Resource): - """The storage account. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Resource Id - :vartype id: str - :ivar name: Resource name - :vartype name: str - :ivar type: Resource type - :vartype type: str - :param location: Resource location - :type location: str - :param tags: Resource tags - :type tags: dict - :param provisioning_state: Gets the status of the storage account at the - time the operation was called. Possible values include: 'Creating', - 'ResolvingDNS', 'Succeeded' - :type provisioning_state: str or :class:`ProvisioningState - ` - :param account_type: Gets the type of the storage account. Possible values - include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - 'Premium_LRS' - :type account_type: str or :class:`AccountType - ` - :param primary_endpoints: Gets the URLs that are used to perform a - retrieval of a public blob, queue or table object.Note that StandardZRS - and PremiumLRS accounts only return the blob endpoint. - :type primary_endpoints: :class:`Endpoints ` - :param primary_location: Gets the location of the primary for the storage - account. - :type primary_location: str - :param status_of_primary: Gets the status indicating whether the primary - location of the storage account is available or unavailable. Possible - values include: 'Available', 'Unavailable' - :type status_of_primary: str or :class:`AccountStatus - ` - :param last_geo_failover_time: Gets the timestamp of the most recent - instance of a failover to the secondary location. Only the most recent - timestamp is retained. This element is not returned if there has never - been a failover instance. Only available if the accountType is StandardGRS - or StandardRAGRS. - :type last_geo_failover_time: datetime - :param secondary_location: Gets the location of the geo replicated - secondary for the storage account. Only available if the accountType is - StandardGRS or StandardRAGRS. - :type secondary_location: str - :param status_of_secondary: Gets the status indicating whether the - secondary location of the storage account is available or unavailable. - Only available if the accountType is StandardGRS or StandardRAGRS. - Possible values include: 'Available', 'Unavailable' - :type status_of_secondary: str or :class:`AccountStatus - ` - :param creation_time: Gets the creation date and time of the storage - account in UTC. - :type creation_time: datetime - :param custom_domain: Gets the user assigned custom domain assigned to - this storage account. - :type custom_domain: :class:`CustomDomain ` - :param secondary_endpoints: Gets the URLs that are used to perform a - retrieval of a public blob, queue or table object from the secondary - location of the storage account. Only available if the accountType is - StandardRAGRS. - :type secondary_endpoints: :class:`Endpoints ` - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'ProvisioningState'}, - 'account_type': {'key': 'properties.accountType', 'type': 'AccountType'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'AccountStatus'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'AccountStatus'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - } - - def __init__(self, location=None, tags=None, provisioning_state=None, account_type=None, primary_endpoints=None, primary_location=None, status_of_primary=None, last_geo_failover_time=None, secondary_location=None, status_of_secondary=None, creation_time=None, custom_domain=None, secondary_endpoints=None): - super(StorageAccount, self).__init__(location=location, tags=tags) - self.provisioning_state = provisioning_state - self.account_type = account_type - self.primary_endpoints = primary_endpoints - self.primary_location = primary_location - self.status_of_primary = status_of_primary - self.last_geo_failover_time = last_geo_failover_time - self.secondary_location = secondary_location - self.status_of_secondary = status_of_secondary - self.creation_time = creation_time - self.custom_domain = custom_domain - self.secondary_endpoints = secondary_endpoints +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_account_check_name_availability_parameters.py b/Samples/2a-validation/Python/storage/models/storage_account_check_name_availability_parameters.py index 51cb9ef61..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_account_check_name_availability_parameters.py +++ b/Samples/2a-validation/Python/storage/models/storage_account_check_name_availability_parameters.py @@ -1,31 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class StorageAccountCheckNameAvailabilityParameters(Model): - """StorageAccountCheckNameAvailabilityParameters. - - :param name: - :type name: str - :param type: Default value: "Microsoft.Storage/storageAccounts" . - :type type: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__(self, name, type="Microsoft.Storage/storageAccounts"): - self.name = name - self.type = type +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_account_create_parameters.py b/Samples/2a-validation/Python/storage/models/storage_account_create_parameters.py index 214160ae1..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_account_create_parameters.py +++ b/Samples/2a-validation/Python/storage/models/storage_account_create_parameters.py @@ -1,39 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class StorageAccountCreateParameters(Model): - """The parameters to provide for the account. - - :param location: Resource location - :type location: str - :param tags: Resource tags - :type tags: dict - :param account_type: Gets or sets the account type. Possible values - include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - 'Premium_LRS' - :type account_type: str or :class:`AccountType - ` - """ - - _validation = { - 'location': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'account_type': {'key': 'properties.accountType', 'type': 'AccountType'}, - } - - def __init__(self, location, account_type, tags=None): - self.location = location - self.tags = tags - self.account_type = account_type +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_account_keys.py b/Samples/2a-validation/Python/storage/models/storage_account_keys.py index 341845ea4..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_account_keys.py +++ b/Samples/2a-validation/Python/storage/models/storage_account_keys.py @@ -1,27 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class StorageAccountKeys(Model): - """The access keys for the storage account. - - :param key1: Gets the value of key 1. - :type key1: str - :param key2: Gets the value of key 2. - :type key2: str - """ - - _attribute_map = { - 'key1': {'key': 'key1', 'type': 'str'}, - 'key2': {'key': 'key2', 'type': 'str'}, - } - - def __init__(self, key1=None, key2=None): - self.key1 = key1 - self.key2 = key2 +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_account_paged.py b/Samples/2a-validation/Python/storage/models/storage_account_paged.py index 7bc4c9305..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_account_paged.py +++ b/Samples/2a-validation/Python/storage/models/storage_account_paged.py @@ -1,23 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class StorageAccountPaged(Paged): - """ - A paging container for iterating over a list of :class:`StorageAccount ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[StorageAccount]'} - } - - def __init__(self, *args, **kwargs): - - super(StorageAccountPaged, self).__init__(*args, **kwargs) +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_account_regenerate_key_parameters.py b/Samples/2a-validation/Python/storage/models/storage_account_regenerate_key_parameters.py index eb73926a3..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_account_regenerate_key_parameters.py +++ b/Samples/2a-validation/Python/storage/models/storage_account_regenerate_key_parameters.py @@ -1,27 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class StorageAccountRegenerateKeyParameters(Model): - """StorageAccountRegenerateKeyParameters. - - :param key_name: - :type key_name: str - """ - - _validation = { - 'key_name': {'required': True}, - } - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__(self, key_name): - self.key_name = key_name +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_account_update_parameters.py b/Samples/2a-validation/Python/storage/models/storage_account_update_parameters.py index 5717f640e..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_account_update_parameters.py +++ b/Samples/2a-validation/Python/storage/models/storage_account_update_parameters.py @@ -1,39 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class StorageAccountUpdateParameters(Model): - """The parameters to update on the account. - - :param tags: Resource tags - :type tags: dict - :param account_type: Gets or sets the account type. Note that StandardZRS - and PremiumLRS accounts cannot be changed to other account types, and - other account types cannot be changed to StandardZRS or PremiumLRS. - Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - 'Standard_RAGRS', 'Premium_LRS' - :type account_type: str or :class:`AccountType - ` - :param custom_domain: User domain assigned to the storage account. Name is - the CNAME source. Only one custom domain is supported per storage account - at this time. To clear the existing custom domain, use an empty string for - the custom domain name property. - :type custom_domain: :class:`CustomDomain ` - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'account_type': {'key': 'properties.accountType', 'type': 'AccountType'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - } - - def __init__(self, tags=None, account_type=None, custom_domain=None): - self.tags = tags - self.account_type = account_type - self.custom_domain = custom_domain +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/storage_management_client_enums.py b/Samples/2a-validation/Python/storage/models/storage_management_client_enums.py index 17e72b3c1..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/storage_management_client_enums.py +++ b/Samples/2a-validation/Python/storage/models/storage_management_client_enums.py @@ -1,46 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum - - -class Reason(Enum): - - account_name_invalid = "AccountNameInvalid" - already_exists = "AlreadyExists" - - -class AccountType(Enum): - - standard_lrs = "Standard_LRS" - standard_zrs = "Standard_ZRS" - standard_grs = "Standard_GRS" - standard_ragrs = "Standard_RAGRS" - premium_lrs = "Premium_LRS" - - -class ProvisioningState(Enum): - - creating = "Creating" - resolving_dns = "ResolvingDNS" - succeeded = "Succeeded" - - -class AccountStatus(Enum): - - available = "Available" - unavailable = "Unavailable" - - -class UsageUnit(Enum): - - count = "Count" - bytes = "Bytes" - seconds = "Seconds" - percent = "Percent" - counts_per_second = "CountsPerSecond" - bytes_per_second = "BytesPerSecond" +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/usage.py b/Samples/2a-validation/Python/storage/models/usage.py index ff947ae8d..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/usage.py +++ b/Samples/2a-validation/Python/storage/models/usage.py @@ -1,46 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class Usage(Model): - """Describes Storage Resource Usage. - - :param unit: Gets the unit of measurement. Possible values include: - 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - 'BytesPerSecond' - :type unit: str or :class:`UsageUnit ` - :param current_value: Gets the current count of the allocated resources in - the subscription. - :type current_value: int - :param limit: Gets the maximum count of the resources that can be - allocated in the subscription. - :type limit: int - :param name: Gets the name of the type of usage. - :type name: :class:`UsageName ` - """ - - _validation = { - 'unit': {'required': True}, - 'current_value': {'required': True}, - 'limit': {'required': True}, - 'name': {'required': True}, - } - - _attribute_map = { - 'unit': {'key': 'unit', 'type': 'UsageUnit'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, - } - - def __init__(self, unit, current_value, limit, name): - self.unit = unit - self.current_value = current_value - self.limit = limit - self.name = name +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/usage_name.py b/Samples/2a-validation/Python/storage/models/usage_name.py index 87b46463b..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/usage_name.py +++ b/Samples/2a-validation/Python/storage/models/usage_name.py @@ -1,28 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class UsageName(Model): - """The Usage Names. - - :param value: Gets a string describing the resource name. - :type value: str - :param localized_value: Gets a localized string describing the resource - name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__(self, value=None, localized_value=None): - self.value = value - self.localized_value = localized_value +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/models/usage_paged.py b/Samples/2a-validation/Python/storage/models/usage_paged.py index 267959875..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/models/usage_paged.py +++ b/Samples/2a-validation/Python/storage/models/usage_paged.py @@ -1,23 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class UsagePaged(Paged): - """ - A paging container for iterating over a list of :class:`Usage ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Usage]'} - } - - def __init__(self, *args, **kwargs): - - super(UsagePaged, self).__init__(*args, **kwargs) +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/operations/__init__.py b/Samples/2a-validation/Python/storage/operations/__init__.py index d579bfcc1..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/operations/__init__.py +++ b/Samples/2a-validation/Python/storage/operations/__init__.py @@ -1,14 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .storage_accounts_operations import StorageAccountsOperations -from .usage_operations import UsageOperations - -__all__ = [ - 'StorageAccountsOperations', - 'UsageOperations', -] +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/operations/storage_accounts_operations.py b/Samples/2a-validation/Python/storage/operations/storage_accounts_operations.py index 15beeca8a..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/operations/storage_accounts_operations.py +++ b/Samples/2a-validation/Python/storage/operations/storage_accounts_operations.py @@ -1,696 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrestazure.azure_operation import AzureOperationPoller - -from .. import models - - -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - :ivar api_version: Client Api Version. Constant value: "2015-06-15". - """ - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2015-06-15" - - self.config = config - - def check_name_availability( - self, account_name, custom_headers=None, raw=False, **operation_config): - """Checks that account name is valid and is not in use. - - :param account_name: The name of the storage account within the - specified resource group. Storage account names must be between 3 and - 24 characters in length and use numbers and lower-case letters only. - :type account_name: - :class:`StorageAccountCheckNameAvailabilityParameters - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: :class:`CheckNameAvailabilityResult - ` or - :class:`ClientRawResponse` if - raw=true - :rtype: :class:`CheckNameAvailabilityResult - ` or - :class:`ClientRawResponse` - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('CheckNameAvailabilityResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def create( - self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): - """Asynchronously creates a new storage account with the specified - parameters. Existing accounts cannot be updated with this API and - should instead use the Update Storage Account API. If an account is - already created and subsequent PUT request is issued with exact same - set of properties, then HTTP 200 would be returned. . - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the - specified resource group. Storage account names must be between 3 and - 24 characters in length and use numbers and lower-case letters only. - :type account_name: str - :param parameters: The parameters to provide for the created account. - :type parameters: :class:`StorageAccountCreateParameters - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: - :class:`AzureOperationPoller` - instance that returns :class:`StorageAccount - ` or - :class:`ClientRawResponse` if - raw=true - :rtype: - :class:`AzureOperationPoller` - or :class:`ClientRawResponse` - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'StorageAccountCreateParameters') - - # Construct and send request - def long_running_send(): - - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) - - def get_long_running_status(status_link, headers=None): - - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) - - def get_long_running_output(response): - - if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - if raw: - response = long_running_send() - return get_long_running_output(response) - - long_running_operation_timeout = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - return AzureOperationPoller( - long_running_send, get_long_running_output, - get_long_running_status, long_running_operation_timeout) - - def delete( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Deletes a storage account in Microsoft Azure. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the - specified resource group. Storage account names must be between 3 and - 24 characters in length and use numbers and lower-case letters only. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or - :class:`ClientRawResponse` if - raw=true - :rtype: None or - :class:`ClientRawResponse` - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def get_properties( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Returns the properties for the specified storage account including but - not limited to name, account type, location, and account status. The - ListKeys operation should be used to retrieve storage keys. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the - specified resource group. Storage account names must be between 3 and - 24 characters in length and use numbers and lower-case letters only. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: :class:`StorageAccount ` or - :class:`ClientRawResponse` if - raw=true - :rtype: :class:`StorageAccount ` or - :class:`ClientRawResponse` - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def update( - self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates the account type or tags for a storage account. It can also be - used to add a custom domain (note that custom domains cannot be added - via the Create operation). Only one custom domain is supported per - storage account. In order to replace a custom domain, the old value - must be cleared before a new value may be set. To clear a custom - domain, simply update the custom domain with empty string. Then call - update again with the new cutsom domain name. The update API can only - be used to update one of tags, accountType, or customDomain per call. - To update multiple of these properties, call the API multiple times - with one change per call. This call does not change the storage keys - for the account. If you want to change storage account keys, use the - RegenerateKey operation. The location and name of the storage account - cannot be changed after creation. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the - specified resource group. Storage account names must be between 3 and - 24 characters in length and use numbers and lower-case letters only. - :type account_name: str - :param parameters: The parameters to update on the account. Note that - only one property can be changed at a time using this API. - :type parameters: :class:`StorageAccountUpdateParameters - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: :class:`StorageAccount ` or - :class:`ClientRawResponse` if - raw=true - :rtype: :class:`StorageAccount ` or - :class:`ClientRawResponse` - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'StorageAccountUpdateParameters') - - # Construct and send request - request = self._client.patch(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def list_keys( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the access keys for the specified storage account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param account_name: The name of the storage account. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: :class:`StorageAccountKeys - ` or - :class:`ClientRawResponse` if - raw=true - :rtype: :class:`StorageAccountKeys - ` or - :class:`ClientRawResponse` - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('StorageAccountKeys', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def list( - self, custom_headers=None, raw=False, **operation_config): - """Lists all the storage accounts available under the subscription. Note - that storage keys are not returned; use the ListKeys operation for - this. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of :class:`StorageAccount - ` - :rtype: :class:`StorageAccountPaged - ` - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - deserialized = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - - def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): - """Lists all the storage accounts available under the given resource - group. Note that storage keys are not returned; use the ListKeys - operation for this. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of :class:`StorageAccount - ` - :rtype: :class:`StorageAccountPaged - ` - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - deserialized = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - - def regenerate_key( - self, resource_group_name, account_name, regenerate_key, custom_headers=None, raw=False, **operation_config): - """Regenerates the access keys for the specified storage account. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the - specified resource group. Storage account names must be between 3 and - 24 characters in length and use numbers and lower-case letters only. - :type account_name: str - :param regenerate_key: Specifies name of the key which should be - regenerated. key1 or key2 for the default keys - :type regenerate_key: :class:`StorageAccountRegenerateKeyParameters - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: :class:`StorageAccountKeys - ` or - :class:`ClientRawResponse` if - raw=true - :rtype: :class:`StorageAccountKeys - ` or - :class:`ClientRawResponse` - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('StorageAccountKeys', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/operations/usage_operations.py b/Samples/2a-validation/Python/storage/operations/usage_operations.py index 31cc00b3c..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/operations/usage_operations.py +++ b/Samples/2a-validation/Python/storage/operations/usage_operations.py @@ -1,97 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class UsageOperations(object): - """UsageOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - :ivar api_version: Client Api Version. Constant value: "2015-06-15". - """ - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2015-06-15" - - self.config = config - - def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the current usage count and the limit for the resources under the - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of :class:`Usage - ` - :rtype: :class:`UsagePaged ` - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - deserialized = models.UsagePaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.UsagePaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/storage_management_client.py b/Samples/2a-validation/Python/storage/storage_management_client.py index 34abb2772..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/storage_management_client.py +++ b/Samples/2a-validation/Python/storage/storage_management_client.py @@ -1,88 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.service_client import ServiceClient -from msrest import Serializer, Deserializer -from msrestazure import AzureConfiguration -from .version import VERSION -from .operations.storage_accounts_operations import StorageAccountsOperations -from .operations.usage_operations import UsageOperations -from . import models - - -class StorageManagementClientConfiguration(AzureConfiguration): - """Configuration for StorageManagementClient - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Gets subscription credentials which uniquely - identify Microsoft Azure subscription. The subscription ID forms part of - the URI for every service call. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - if not isinstance(subscription_id, str): - raise TypeError("Parameter 'subscription_id' must be str.") - if not base_url: - base_url = 'https://management.azure.com' - - super(StorageManagementClientConfiguration, self).__init__(base_url) - - self.add_user_agent('storagemanagementclient/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials - self.subscription_id = subscription_id - - -class StorageManagementClient(object): - """The Storage Management Client. - - :ivar config: Configuration for client. - :vartype config: StorageManagementClientConfiguration - - :ivar storage_accounts: StorageAccounts operations - :vartype storage_accounts: storage.operations.StorageAccountsOperations - :ivar usage: Usage operations - :vartype usage: storage.operations.UsageOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Gets subscription credentials which uniquely - identify Microsoft Azure subscription. The subscription ID forms part of - the URI for every service call. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = StorageManagementClientConfiguration(credentials, subscription_id, base_url) - self._client = ServiceClient(self.config.credentials, self.config) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2015-06-15' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.storage_accounts = StorageAccountsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.usage = UsageOperations( - self._client, self.config, self._serialize, self._deserialize) +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Python/storage/version.py b/Samples/2a-validation/Python/storage/version.py index 3baca858a..9d6cafc2c 100644 --- a/Samples/2a-validation/Python/storage/version.py +++ b/Samples/2a-validation/Python/storage/version.py @@ -1,9 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2015-06-15" - +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage.rb b/Samples/2a-validation/Ruby/generated/storage.rb index 1c57a516a..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage.rb +++ b/Samples/2a-validation/Ruby/generated/storage.rb @@ -1,48 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -require 'uri' -require 'cgi' -require 'date' -require 'json' -require 'base64' -require 'erb' -require 'securerandom' -require 'time' -require 'timeliness' -require 'faraday' -require 'faraday-cookie_jar' -require 'concurrent' -require 'ms_rest' -require 'generated/storage/module_definition' -require 'ms_rest_azure' - -module Storage - autoload :StorageAccounts, 'generated/storage/storage_accounts.rb' - autoload :UsageOperations, 'generated/storage/usage_operations.rb' - autoload :StorageManagementClient, 'generated/storage/storage_management_client.rb' - - module Models - autoload :StorageAccountListResult, 'generated/storage/models/storage_account_list_result.rb' - autoload :StorageAccountCheckNameAvailabilityParameters, 'generated/storage/models/storage_account_check_name_availability_parameters.rb' - autoload :StorageAccountUpdateParameters, 'generated/storage/models/storage_account_update_parameters.rb' - autoload :StorageAccountCreateParameters, 'generated/storage/models/storage_account_create_parameters.rb' - autoload :StorageAccountRegenerateKeyParameters, 'generated/storage/models/storage_account_regenerate_key_parameters.rb' - autoload :CustomDomain, 'generated/storage/models/custom_domain.rb' - autoload :UsageName, 'generated/storage/models/usage_name.rb' - autoload :StorageAccountKeys, 'generated/storage/models/storage_account_keys.rb' - autoload :Usage, 'generated/storage/models/usage.rb' - autoload :Endpoints, 'generated/storage/models/endpoints.rb' - autoload :UsageListResult, 'generated/storage/models/usage_list_result.rb' - autoload :CheckNameAvailabilityResult, 'generated/storage/models/check_name_availability_result.rb' - autoload :Resource, 'generated/storage/models/resource.rb' - autoload :StorageAccount, 'generated/storage/models/storage_account.rb' - autoload :Reason, 'generated/storage/models/reason.rb' - autoload :AccountType, 'generated/storage/models/account_type.rb' - autoload :ProvisioningState, 'generated/storage/models/provisioning_state.rb' - autoload :AccountStatus, 'generated/storage/models/account_status.rb' - autoload :UsageUnit, 'generated/storage/models/usage_unit.rb' - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/account_status.rb b/Samples/2a-validation/Ruby/generated/storage/models/account_status.rb index 15b82df1c..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/account_status.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/account_status.rb @@ -1,16 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Defines values for AccountStatus - # - module AccountStatus - Available = "Available" - Unavailable = "Unavailable" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/account_type.rb b/Samples/2a-validation/Ruby/generated/storage/models/account_type.rb index 26d825be2..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/account_type.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/account_type.rb @@ -1,19 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Defines values for AccountType - # - module AccountType - StandardLRS = "Standard_LRS" - StandardZRS = "Standard_ZRS" - StandardGRS = "Standard_GRS" - StandardRAGRS = "Standard_RAGRS" - PremiumLRS = "Premium_LRS" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/check_name_availability_result.rb b/Samples/2a-validation/Ruby/generated/storage/models/check_name_availability_result.rb index fde8b7ec7..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/check_name_availability_result.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/check_name_availability_result.rb @@ -1,70 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The CheckNameAvailability operation response. - # - class CheckNameAvailabilityResult - - include MsRestAzure - - # @return [Boolean] Gets a boolean value that indicates whether the name - # is available for you to use. If true, the name is available. If false, - # the name has already been taken or invalid and cannot be used. - attr_accessor :name_available - - # @return [Reason] Gets the reason that a storage account name could not - # be used. The Reason element is only returned if NameAvailable is false. - # Possible values include: 'AccountNameInvalid', 'AlreadyExists' - attr_accessor :reason - - # @return [String] Gets an error message explaining the Reason value in - # more detail. - attr_accessor :message - - - # - # Mapper for CheckNameAvailabilityResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'CheckNameAvailabilityResult', - type: { - name: 'Composite', - class_name: 'CheckNameAvailabilityResult', - model_properties: { - name_available: { - required: false, - serialized_name: 'nameAvailable', - type: { - name: 'Boolean' - } - }, - reason: { - required: false, - serialized_name: 'reason', - type: { - name: 'Enum', - module: 'Reason' - } - }, - message: { - required: false, - serialized_name: 'message', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/custom_domain.rb b/Samples/2a-validation/Ruby/generated/storage/models/custom_domain.rb index d4e4ea18c..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/custom_domain.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/custom_domain.rb @@ -1,57 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The custom domain assigned to this storage account. This can be set via - # Update. - # - class CustomDomain - - include MsRestAzure - - # @return [String] Gets or sets the custom domain name. Name is the CNAME - # source. - attr_accessor :name - - # @return [Boolean] Indicates whether indirect CName validation is - # enabled. Default value is false. This should only be set on updates - attr_accessor :use_sub_domain - - - # - # Mapper for CustomDomain class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'CustomDomain', - type: { - name: 'Composite', - class_name: 'CustomDomain', - model_properties: { - name: { - required: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - use_sub_domain: { - required: false, - serialized_name: 'useSubDomain', - type: { - name: 'Boolean' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/endpoints.rb b/Samples/2a-validation/Ruby/generated/storage/models/endpoints.rb index ac93f3bcb..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/endpoints.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/endpoints.rb @@ -1,75 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The URIs that are used to perform a retrieval of a public blob, queue or - # table object. - # - class Endpoints - - include MsRestAzure - - # @return [String] Gets the blob endpoint. - attr_accessor :blob - - # @return [String] Gets the queue endpoint. - attr_accessor :queue - - # @return [String] Gets the table endpoint. - attr_accessor :table - - # @return [String] Gets the file endpoint. - attr_accessor :file - - - # - # Mapper for Endpoints class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Endpoints', - type: { - name: 'Composite', - class_name: 'Endpoints', - model_properties: { - blob: { - required: false, - serialized_name: 'blob', - type: { - name: 'String' - } - }, - queue: { - required: false, - serialized_name: 'queue', - type: { - name: 'String' - } - }, - table: { - required: false, - serialized_name: 'table', - type: { - name: 'String' - } - }, - file: { - required: false, - serialized_name: 'file', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/provisioning_state.rb b/Samples/2a-validation/Ruby/generated/storage/models/provisioning_state.rb index 2cd5afa03..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/provisioning_state.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/provisioning_state.rb @@ -1,17 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Defines values for ProvisioningState - # - module ProvisioningState - Creating = "Creating" - ResolvingDNS = "ResolvingDNS" - Succeeded = "Succeeded" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/reason.rb b/Samples/2a-validation/Ruby/generated/storage/models/reason.rb index e49086391..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/reason.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/reason.rb @@ -1,16 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Defines values for Reason - # - module Reason - AccountNameInvalid = "AccountNameInvalid" - AlreadyExists = "AlreadyExists" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/resource.rb b/Samples/2a-validation/Ruby/generated/storage/models/resource.rb index daae15175..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/resource.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/resource.rb @@ -1,95 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Model object. - # - # - class Resource - - include MsRestAzure - - # @return [String] Resource Id - attr_accessor :id - - # @return [String] Resource name - attr_accessor :name - - # @return [String] Resource type - attr_accessor :type - - # @return [String] Resource location - attr_accessor :location - - # @return [Hash{String => String}] Resource tags - attr_accessor :tags - - - # - # Mapper for Resource class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Resource', - type: { - name: 'Composite', - class_name: 'Resource', - model_properties: { - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - read_only: true, - serialized_name: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/storage_account.rb b/Samples/2a-validation/Ruby/generated/storage/models/storage_account.rb index deadf9f22..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/storage_account.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/storage_account.rb @@ -1,219 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The storage account. - # - class StorageAccount < Resource - - include MsRestAzure - - # @return [ProvisioningState] Gets the status of the storage account at - # the time the operation was called. Possible values include: 'Creating', - # 'ResolvingDNS', 'Succeeded' - attr_accessor :provisioning_state - - # @return [AccountType] Gets the type of the storage account. Possible - # values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - # 'Standard_RAGRS', 'Premium_LRS' - attr_accessor :account_type - - # @return [Endpoints] Gets the URLs that are used to perform a retrieval - # of a public blob, queue or table object.Note that StandardZRS and - # PremiumLRS accounts only return the blob endpoint. - attr_accessor :primary_endpoints - - # @return [String] Gets the location of the primary for the storage - # account. - attr_accessor :primary_location - - # @return [AccountStatus] Gets the status indicating whether the primary - # location of the storage account is available or unavailable. Possible - # values include: 'Available', 'Unavailable' - attr_accessor :status_of_primary - - # @return [DateTime] Gets the timestamp of the most recent instance of a - # failover to the secondary location. Only the most recent timestamp is - # retained. This element is not returned if there has never been a - # failover instance. Only available if the accountType is StandardGRS or - # StandardRAGRS. - attr_accessor :last_geo_failover_time - - # @return [String] Gets the location of the geo replicated secondary for - # the storage account. Only available if the accountType is StandardGRS - # or StandardRAGRS. - attr_accessor :secondary_location - - # @return [AccountStatus] Gets the status indicating whether the - # secondary location of the storage account is available or unavailable. - # Only available if the accountType is StandardGRS or StandardRAGRS. - # Possible values include: 'Available', 'Unavailable' - attr_accessor :status_of_secondary - - # @return [DateTime] Gets the creation date and time of the storage - # account in UTC. - attr_accessor :creation_time - - # @return [CustomDomain] Gets the user assigned custom domain assigned to - # this storage account. - attr_accessor :custom_domain - - # @return [Endpoints] Gets the URLs that are used to perform a retrieval - # of a public blob, queue or table object from the secondary location of - # the storage account. Only available if the accountType is - # StandardRAGRS. - attr_accessor :secondary_endpoints - - - # - # Mapper for StorageAccount class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccount', - type: { - name: 'Composite', - class_name: 'StorageAccount', - model_properties: { - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - read_only: true, - serialized_name: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - provisioning_state: { - required: false, - serialized_name: 'properties.provisioningState', - type: { - name: 'Enum', - module: 'ProvisioningState' - } - }, - account_type: { - required: false, - serialized_name: 'properties.accountType', - type: { - name: 'Enum', - module: 'AccountType' - } - }, - primary_endpoints: { - required: false, - serialized_name: 'properties.primaryEndpoints', - type: { - name: 'Composite', - class_name: 'Endpoints' - } - }, - primary_location: { - required: false, - serialized_name: 'properties.primaryLocation', - type: { - name: 'String' - } - }, - status_of_primary: { - required: false, - serialized_name: 'properties.statusOfPrimary', - type: { - name: 'Enum', - module: 'AccountStatus' - } - }, - last_geo_failover_time: { - required: false, - serialized_name: 'properties.lastGeoFailoverTime', - type: { - name: 'DateTime' - } - }, - secondary_location: { - required: false, - serialized_name: 'properties.secondaryLocation', - type: { - name: 'String' - } - }, - status_of_secondary: { - required: false, - serialized_name: 'properties.statusOfSecondary', - type: { - name: 'Enum', - module: 'AccountStatus' - } - }, - creation_time: { - required: false, - serialized_name: 'properties.creationTime', - type: { - name: 'DateTime' - } - }, - custom_domain: { - required: false, - serialized_name: 'properties.customDomain', - type: { - name: 'Composite', - class_name: 'CustomDomain' - } - }, - secondary_endpoints: { - required: false, - serialized_name: 'properties.secondaryEndpoints', - type: { - name: 'Composite', - class_name: 'Endpoints' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_check_name_availability_parameters.rb b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_check_name_availability_parameters.rb index a50d7067c..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_check_name_availability_parameters.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_check_name_availability_parameters.rb @@ -1,57 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Model object. - # - # - class StorageAccountCheckNameAvailabilityParameters - - include MsRestAzure - - # @return [String] - attr_accessor :name - - # @return [String] . Default value: 'Microsoft.Storage/storageAccounts' . - attr_accessor :type - - - # - # Mapper for StorageAccountCheckNameAvailabilityParameters class as Ruby - # Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountCheckNameAvailabilityParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountCheckNameAvailabilityParameters', - model_properties: { - name: { - required: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - serialized_name: 'type', - default_value: 'Microsoft.Storage/storageAccounts', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_create_parameters.rb b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_create_parameters.rb index 5560a5310..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_create_parameters.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_create_parameters.rb @@ -1,74 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The parameters to provide for the account. - # - class StorageAccountCreateParameters - - include MsRestAzure - - # @return [String] Resource location - attr_accessor :location - - # @return [Hash{String => String}] Resource tags - attr_accessor :tags - - # @return [AccountType] Gets or sets the account type. Possible values - # include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - # 'Standard_RAGRS', 'Premium_LRS' - attr_accessor :account_type - - - # - # Mapper for StorageAccountCreateParameters class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountCreateParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountCreateParameters', - model_properties: { - location: { - required: true, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - account_type: { - required: true, - serialized_name: 'properties.accountType', - type: { - name: 'Enum', - module: 'AccountType' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_keys.rb b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_keys.rb index aaa1c6f6a..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_keys.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_keys.rb @@ -1,54 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The access keys for the storage account. - # - class StorageAccountKeys - - include MsRestAzure - - # @return [String] Gets the value of key 1. - attr_accessor :key1 - - # @return [String] Gets the value of key 2. - attr_accessor :key2 - - - # - # Mapper for StorageAccountKeys class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountKeys', - type: { - name: 'Composite', - class_name: 'StorageAccountKeys', - model_properties: { - key1: { - required: false, - serialized_name: 'key1', - type: { - name: 'String' - } - }, - key2: { - required: false, - serialized_name: 'key2', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_list_result.rb b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_list_result.rb index abf4fe54d..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_list_result.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_list_result.rb @@ -1,53 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The list storage accounts operation response. - # - class StorageAccountListResult - - include MsRestAzure - - # @return [Array] Gets the list of storage accounts and - # their properties. - attr_accessor :value - - - # - # Mapper for StorageAccountListResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountListResult', - type: { - name: 'Composite', - class_name: 'StorageAccountListResult', - model_properties: { - value: { - required: false, - serialized_name: 'value', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'StorageAccountElementType', - type: { - name: 'Composite', - class_name: 'StorageAccount' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_regenerate_key_parameters.rb b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_regenerate_key_parameters.rb index 50ee6430c..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_regenerate_key_parameters.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_regenerate_key_parameters.rb @@ -1,45 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Model object. - # - # - class StorageAccountRegenerateKeyParameters - - include MsRestAzure - - # @return [String] - attr_accessor :key_name - - - # - # Mapper for StorageAccountRegenerateKeyParameters class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountRegenerateKeyParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountRegenerateKeyParameters', - model_properties: { - key_name: { - required: true, - serialized_name: 'keyName', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_update_parameters.rb b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_update_parameters.rb index aecb1bdc5..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/storage_account_update_parameters.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/storage_account_update_parameters.rb @@ -1,80 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The parameters to update on the account. - # - class StorageAccountUpdateParameters - - include MsRestAzure - - # @return [Hash{String => String}] Resource tags - attr_accessor :tags - - # @return [AccountType] Gets or sets the account type. Note that - # StandardZRS and PremiumLRS accounts cannot be changed to other account - # types, and other account types cannot be changed to StandardZRS or - # PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', - # 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - attr_accessor :account_type - - # @return [CustomDomain] User domain assigned to the storage account. - # Name is the CNAME source. Only one custom domain is supported per - # storage account at this time. To clear the existing custom domain, use - # an empty string for the custom domain name property. - attr_accessor :custom_domain - - - # - # Mapper for StorageAccountUpdateParameters class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountUpdateParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountUpdateParameters', - model_properties: { - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - account_type: { - required: false, - serialized_name: 'properties.accountType', - type: { - name: 'Enum', - module: 'AccountType' - } - }, - custom_domain: { - required: false, - serialized_name: 'properties.customDomain', - type: { - name: 'Composite', - class_name: 'CustomDomain' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/usage.rb b/Samples/2a-validation/Ruby/generated/storage/models/usage.rb index 72c612577..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/usage.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/usage.rb @@ -1,80 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Describes Storage Resource Usage. - # - class Usage - - include MsRestAzure - - # @return [UsageUnit] Gets the unit of measurement. Possible values - # include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - # 'BytesPerSecond' - attr_accessor :unit - - # @return [Integer] Gets the current count of the allocated resources in - # the subscription. - attr_accessor :current_value - - # @return [Integer] Gets the maximum count of the resources that can be - # allocated in the subscription. - attr_accessor :limit - - # @return [UsageName] Gets the name of the type of usage. - attr_accessor :name - - - # - # Mapper for Usage class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Usage', - type: { - name: 'Composite', - class_name: 'Usage', - model_properties: { - unit: { - required: true, - serialized_name: 'unit', - type: { - name: 'Enum', - module: 'UsageUnit' - } - }, - current_value: { - required: true, - serialized_name: 'currentValue', - type: { - name: 'Number' - } - }, - limit: { - required: true, - serialized_name: 'limit', - type: { - name: 'Number' - } - }, - name: { - required: true, - serialized_name: 'name', - type: { - name: 'Composite', - class_name: 'UsageName' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/usage_list_result.rb b/Samples/2a-validation/Ruby/generated/storage/models/usage_list_result.rb index 48be558ac..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/usage_list_result.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/usage_list_result.rb @@ -1,52 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The List Usages operation response. - # - class UsageListResult - - include MsRestAzure - - # @return [Array] Gets or sets the list Storage Resource Usages. - attr_accessor :value - - - # - # Mapper for UsageListResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'UsageListResult', - type: { - name: 'Composite', - class_name: 'UsageListResult', - model_properties: { - value: { - required: false, - serialized_name: 'value', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'UsageElementType', - type: { - name: 'Composite', - class_name: 'Usage' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/usage_name.rb b/Samples/2a-validation/Ruby/generated/storage/models/usage_name.rb index 83340cff9..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/usage_name.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/usage_name.rb @@ -1,54 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # The Usage Names. - # - class UsageName - - include MsRestAzure - - # @return [String] Gets a string describing the resource name. - attr_accessor :value - - # @return [String] Gets a localized string describing the resource name. - attr_accessor :localized_value - - - # - # Mapper for UsageName class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'UsageName', - type: { - name: 'Composite', - class_name: 'UsageName', - model_properties: { - value: { - required: false, - serialized_name: 'value', - type: { - name: 'String' - } - }, - localized_value: { - required: false, - serialized_name: 'localizedValue', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/models/usage_unit.rb b/Samples/2a-validation/Ruby/generated/storage/models/usage_unit.rb index 1dc8e7c2f..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/models/usage_unit.rb +++ b/Samples/2a-validation/Ruby/generated/storage/models/usage_unit.rb @@ -1,20 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - module Models - # - # Defines values for UsageUnit - # - module UsageUnit - Count = "Count" - Bytes = "Bytes" - Seconds = "Seconds" - Percent = "Percent" - CountsPerSecond = "CountsPerSecond" - BytesPerSecond = "BytesPerSecond" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/module_definition.rb b/Samples/2a-validation/Ruby/generated/storage/module_definition.rb index 462ef2f77..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/module_definition.rb +++ b/Samples/2a-validation/Ruby/generated/storage/module_definition.rb @@ -1,6 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/storage_accounts.rb b/Samples/2a-validation/Ruby/generated/storage/storage_accounts.rb index 42921be5f..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/storage_accounts.rb +++ b/Samples/2a-validation/Ruby/generated/storage/storage_accounts.rb @@ -1,1047 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - # - # The Storage Management Client. - # - class StorageAccounts - include MsRestAzure - - # - # Creates and initializes a new instance of the StorageAccounts class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [StorageManagementClient] reference to the StorageManagementClient - attr_reader :client - - # - # Checks that account name is valid and is not in use. - # - # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name - # of the storage account within the specified resource group. Storage account - # names must be between 3 and 24 characters in length and use numbers and - # lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [CheckNameAvailabilityResult] operation results. - # - def check_name_availability(account_name, custom_headers = nil) - response = check_name_availability_async(account_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Checks that account name is valid and is not in use. - # - # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name - # of the storage account within the specified resource group. Storage account - # names must be between 3 and 24 characters in length and use numbers and - # lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def check_name_availability_with_http_info(account_name, custom_headers = nil) - check_name_availability_async(account_name, custom_headers).value! - end - - # - # Checks that account name is valid and is not in use. - # - # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name - # of the storage account within the specified resource group. Storage account - # names must be between 3 and 24 characters in length and use numbers and - # lower-case letters only. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def check_name_availability_async(account_name, custom_headers = nil) - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Storage::Models::StorageAccountCheckNameAvailabilityParameters.mapper() - request_content = @client.serialize(request_mapper, account_name) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::CheckNameAvailabilityResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Asynchronously creates a new storage account with the specified parameters. - # Existing accounts cannot be updated with this API and should instead use the - # Update Storage Account API. If an account is already created and subsequent - # PUT request is issued with exact same set of properties, then HTTP 200 would - # be returned. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccount] operation results. - # - def create(resource_group_name, account_name, parameters, custom_headers = nil) - response = create_async(resource_group_name, account_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def create_async(resource_group_name, account_name, parameters, custom_headers = nil) - # Send request - promise = begin_create_async(resource_group_name, account_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Storage::Models::StorageAccount.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Deletes a storage account in Microsoft Azure. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def delete(resource_group_name, account_name, custom_headers = nil) - response = delete_async(resource_group_name, account_name, custom_headers).value! - nil - end - - # - # Deletes a storage account in Microsoft Azure. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def delete_with_http_info(resource_group_name, account_name, custom_headers = nil) - delete_async(resource_group_name, account_name, custom_headers).value! - end - - # - # Deletes a storage account in Microsoft Azure. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def delete_async(resource_group_name, account_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:delete, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 || status_code == 204 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - - result - end - - promise.execute - end - - # - # Returns the properties for the specified storage account including but not - # limited to name, account type, location, and account status. The ListKeys - # operation should be used to retrieve storage keys. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccount] operation results. - # - def get_properties(resource_group_name, account_name, custom_headers = nil) - response = get_properties_async(resource_group_name, account_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns the properties for the specified storage account including but not - # limited to name, account type, location, and account status. The ListKeys - # operation should be used to retrieve storage keys. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def get_properties_with_http_info(resource_group_name, account_name, custom_headers = nil) - get_properties_async(resource_group_name, account_name, custom_headers).value! - end - - # - # Returns the properties for the specified storage account including but not - # limited to name, account type, location, and account status. The ListKeys - # operation should be used to retrieve storage keys. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def get_properties_async(resource_group_name, account_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::StorageAccount.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Updates the account type or tags for a storage account. It can also be used - # to add a custom domain (note that custom domains cannot be added via the - # Create operation). Only one custom domain is supported per storage account. - # In order to replace a custom domain, the old value must be cleared before a - # new value may be set. To clear a custom domain, simply update the custom - # domain with empty string. Then call update again with the new cutsom domain - # name. The update API can only be used to update one of tags, accountType, or - # customDomain per call. To update multiple of these properties, call the API - # multiple times with one change per call. This call does not change the - # storage keys for the account. If you want to change storage account keys, use - # the RegenerateKey operation. The location and name of the storage account - # cannot be changed after creation. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountUpdateParameters] The parameters to update - # on the account. Note that only one property can be changed at a time using - # this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccount] operation results. - # - def update(resource_group_name, account_name, parameters, custom_headers = nil) - response = update_async(resource_group_name, account_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Updates the account type or tags for a storage account. It can also be used - # to add a custom domain (note that custom domains cannot be added via the - # Create operation). Only one custom domain is supported per storage account. - # In order to replace a custom domain, the old value must be cleared before a - # new value may be set. To clear a custom domain, simply update the custom - # domain with empty string. Then call update again with the new cutsom domain - # name. The update API can only be used to update one of tags, accountType, or - # customDomain per call. To update multiple of these properties, call the API - # multiple times with one change per call. This call does not change the - # storage keys for the account. If you want to change storage account keys, use - # the RegenerateKey operation. The location and name of the storage account - # cannot be changed after creation. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountUpdateParameters] The parameters to update - # on the account. Note that only one property can be changed at a time using - # this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def update_with_http_info(resource_group_name, account_name, parameters, custom_headers = nil) - update_async(resource_group_name, account_name, parameters, custom_headers).value! - end - - # - # Updates the account type or tags for a storage account. It can also be used - # to add a custom domain (note that custom domains cannot be added via the - # Create operation). Only one custom domain is supported per storage account. - # In order to replace a custom domain, the old value must be cleared before a - # new value may be set. To clear a custom domain, simply update the custom - # domain with empty string. Then call update again with the new cutsom domain - # name. The update API can only be used to update one of tags, accountType, or - # customDomain per call. To update multiple of these properties, call the API - # multiple times with one change per call. This call does not change the - # storage keys for the account. If you want to change storage account keys, use - # the RegenerateKey operation. The location and name of the storage account - # cannot be changed after creation. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountUpdateParameters] The parameters to update - # on the account. Note that only one property can be changed at a time using - # this API. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def update_async(resource_group_name, account_name, parameters, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, 'parameters is nil' if parameters.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Storage::Models::StorageAccountUpdateParameters.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:patch, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::StorageAccount.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Lists the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group. - # @param account_name [String] The name of the storage account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountKeys] operation results. - # - def list_keys(resource_group_name, account_name, custom_headers = nil) - response = list_keys_async(resource_group_name, account_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Lists the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group. - # @param account_name [String] The name of the storage account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def list_keys_with_http_info(resource_group_name, account_name, custom_headers = nil) - list_keys_async(resource_group_name, account_name, custom_headers).value! - end - - # - # Lists the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group. - # @param account_name [String] The name of the storage account. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_keys_async(resource_group_name, account_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::StorageAccountKeys.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Lists all the storage accounts available under the subscription. Note that - # storage keys are not returned; use the ListKeys operation for this. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountListResult] operation results. - # - def list(custom_headers = nil) - response = list_async(custom_headers).value! - response.body unless response.nil? - end - - # - # Lists all the storage accounts available under the subscription. Note that - # storage keys are not returned; use the ListKeys operation for this. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def list_with_http_info(custom_headers = nil) - list_async(custom_headers).value! - end - - # - # Lists all the storage accounts available under the subscription. Note that - # storage keys are not returned; use the ListKeys operation for this. - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_async(custom_headers = nil) - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::StorageAccountListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Lists all the storage accounts available under the given resource group. Note - # that storage keys are not returned; use the ListKeys operation for this. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountListResult] operation results. - # - def list_by_resource_group(resource_group_name, custom_headers = nil) - response = list_by_resource_group_async(resource_group_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Lists all the storage accounts available under the given resource group. Note - # that storage keys are not returned; use the ListKeys operation for this. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def list_by_resource_group_with_http_info(resource_group_name, custom_headers = nil) - list_by_resource_group_async(resource_group_name, custom_headers).value! - end - - # - # Lists all the storage accounts available under the given resource group. Note - # that storage keys are not returned; use the ListKeys operation for this. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_by_resource_group_async(resource_group_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::StorageAccountListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Regenerates the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name - # of the key which should be regenerated. key1 or key2 for the default keys - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountKeys] operation results. - # - def regenerate_key(resource_group_name, account_name, regenerate_key, custom_headers = nil) - response = regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers).value! - response.body unless response.nil? - end - - # - # Regenerates the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name - # of the key which should be regenerated. key1 or key2 for the default keys - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def regenerate_key_with_http_info(resource_group_name, account_name, regenerate_key, custom_headers = nil) - regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers).value! - end - - # - # Regenerates the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name - # of the key which should be regenerated. key1 or key2 for the default keys - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, 'regenerate_key is nil' if regenerate_key.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Storage::Models::StorageAccountRegenerateKeyParameters.mapper() - request_content = @client.serialize(request_mapper, regenerate_key) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::StorageAccountKeys.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Asynchronously creates a new storage account with the specified parameters. - # Existing accounts cannot be updated with this API and should instead use the - # Update Storage Account API. If an account is already created and subsequent - # PUT request is issued with exact same set of properties, then HTTP 200 would - # be returned. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccount] operation results. - # - def begin_create(resource_group_name, account_name, parameters, custom_headers = nil) - response = begin_create_async(resource_group_name, account_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Asynchronously creates a new storage account with the specified parameters. - # Existing accounts cannot be updated with this API and should instead use the - # Update Storage Account API. If an account is already created and subsequent - # PUT request is issued with exact same set of properties, then HTTP 200 would - # be returned. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def begin_create_with_http_info(resource_group_name, account_name, parameters, custom_headers = nil) - begin_create_async(resource_group_name, account_name, parameters, custom_headers).value! - end - - # - # Asynchronously creates a new storage account with the specified parameters. - # Existing accounts cannot be updated with this API and should instead use the - # Update Storage Account API. If an account is already created and subsequent - # PUT request is issued with exact same set of properties, then HTTP 200 would - # be returned. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def begin_create_async(resource_group_name, account_name, parameters, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, 'parameters is nil' if parameters.nil? - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Storage::Models::StorageAccountCreateParameters.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:put, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 || status_code == 202 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::StorageAccount.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/storage_management_client.rb b/Samples/2a-validation/Ruby/generated/storage/storage_management_client.rb index 491db0ffd..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/storage_management_client.rb +++ b/Samples/2a-validation/Ruby/generated/storage/storage_management_client.rb @@ -1,135 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - # - # A service client - single point of access to the REST API. - # - class StorageManagementClient < MsRestAzure::AzureServiceClient - include MsRestAzure - include MsRestAzure::Serialization - - # @return [String] the base URI of the service. - attr_accessor :base_url - - # @return Credentials needed for the client to connect to Azure. - attr_reader :credentials - - # @return [String] Gets subscription credentials which uniquely identify - # Microsoft Azure subscription. The subscription ID forms part of the URI - # for every service call. - attr_accessor :subscription_id - - # @return [String] Client Api Version. - attr_reader :api_version - - # @return [String] Gets or sets the preferred language for the response. - attr_accessor :accept_language - - # @return [Integer] Gets or sets the retry timeout in seconds for Long - # Running Operations. Default value is 30. - attr_accessor :long_running_operation_retry_timeout - - # @return [Boolean] When set to true a unique x-ms-client-request-id value - # is generated and included in each request. Default is true. - attr_accessor :generate_client_request_id - - # @return [StorageAccounts] storage_accounts - attr_reader :storage_accounts - - # @return [UsageOperations] usage_operations - attr_reader :usage_operations - - # - # Creates initializes a new instance of the StorageManagementClient class. - # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. - # @param base_url [String] the base URI of the service. - # @param options [Array] filters to be applied to the HTTP requests. - # - def initialize(credentials = nil, base_url = nil, options = nil) - super(credentials, options) - @base_url = base_url || 'https://management.azure.com' - - fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? - @credentials = credentials - - @storage_accounts = StorageAccounts.new(self) - @usage_operations = UsageOperations.new(self) - @api_version = '2015-06-15' - @accept_language = 'en-US' - @long_running_operation_retry_timeout = 30 - @generate_client_request_id = true - add_telemetry - end - - # - # Makes a request and returns the body of the response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Hash{String=>String}] containing the body of the response. - # Example: - # - # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}" - # path = "/path" - # options = { - # body: request_content, - # query_params: {'api-version' => '2016-02-01'} - # } - # result = @client.make_request(:put, path, options) - # - def make_request(method, path, options = {}) - result = make_request_with_http_info(method, path, options) - result.body unless result.nil? - end - - # - # Makes a request and returns the operation response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status. - # - def make_request_with_http_info(method, path, options = {}) - result = make_request_async(method, path, options).value! - result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body) - result - end - - # - # Makes a request asynchronously. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def make_request_async(method, path, options = {}) - fail ArgumentError, 'method is nil' if method.nil? - fail ArgumentError, 'path is nil' if path.nil? - - request_url = options[:base_url] || @base_url - - request_headers = @request_headers - request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil? - options.merge!({headers: request_headers.merge(options[:headers] || {})}) - options.merge!({credentials: @credentials}) unless @credentials.nil? - - super(request_url, method, path, options) - end - - - private - # - # Adds telemetry information. - # - def add_telemetry - sdk_information = 'storage' - if defined? Storage::VERSION - sdk_information = "#{sdk_information}/#{Storage::VERSION}" - end - add_user_agent_information(sdk_information) - end - end -end +SRC \ No newline at end of file diff --git a/Samples/2a-validation/Ruby/generated/storage/usage_operations.rb b/Samples/2a-validation/Ruby/generated/storage/usage_operations.rb index 304463c87..9d6cafc2c 100644 --- a/Samples/2a-validation/Ruby/generated/storage/usage_operations.rb +++ b/Samples/2a-validation/Ruby/generated/storage/usage_operations.rb @@ -1,111 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Storage - # - # The Storage Management Client. - # - class UsageOperations - include MsRestAzure - - # - # Creates and initializes a new instance of the UsageOperations class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [StorageManagementClient] reference to the StorageManagementClient - attr_reader :client - - # - # Gets the current usage count and the limit for the resources under the - # subscription. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [UsageListResult] operation results. - # - def list(custom_headers = nil) - response = list_async(custom_headers).value! - response.body unless response.nil? - end - - # - # Gets the current usage count and the limit for the resources under the - # subscription. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def list_with_http_info(custom_headers = nil) - list_async(custom_headers).value! - end - - # - # Gets the current usage count and the limit for the resources under the - # subscription. - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_async(custom_headers = nil) - fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => @client.api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Storage::Models::UsageListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/IQueryKeysOperations.cs b/Samples/3a-literate-swagger/Client/IQueryKeysOperations.cs index 45e5153fc..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/IQueryKeysOperations.cs +++ b/Samples/3a-literate-swagger/Client/IQueryKeysOperations.cs @@ -1,53 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// QueryKeysOperations operations. - /// - public partial interface IQueryKeysOperations - { - /// - /// > `#QueryKeys_List` searches for an object that has a string - /// property containing "QueryKeys_List". - /// - /// Returns the list of query API keys for the given Azure Search - /// service. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(string resourceGroupName, string serviceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/ISearchManagementClient.cs b/Samples/3a-literate-swagger/Client/ISearchManagementClient.cs index b354a06dd..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/ISearchManagementClient.cs +++ b/Samples/3a-literate-swagger/Client/ISearchManagementClient.cs @@ -1,84 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - - /// - /// > the above JSON query pushes this markdown section into node - /// `$.info.description` of the OpenAPI definition. - /// - /// This client that can be used to manage Azure Search services and API - /// keys. - /// - public partial interface ISearchManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. - /// The subscription ID forms part of the URI for every service call. - /// - string SubscriptionId { get; set; } - - /// - /// The client API version. - /// - string ApiVersion { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// Gets the IQueryKeysOperations. - /// - IQueryKeysOperations QueryKeys { get; } - - /// - /// Gets the IServicesOperations. - /// - IServicesOperations Services { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/IServicesOperations.cs b/Samples/3a-literate-swagger/Client/IServicesOperations.cs index c8b363124..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/IServicesOperations.cs +++ b/Samples/3a-literate-swagger/Client/IServicesOperations.cs @@ -1,101 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ServicesOperations operations. - /// - public partial interface IServicesOperations - { - /// - /// Creates or updates a Search service in the given resource group. - /// If the Search service already exists, all properties will be - /// updated with the given values. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The properties to set or update on the Search service. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serviceName, SearchServiceCreateOrUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a Search service in the given resource group, along with - /// its associated resources. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serviceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns a list of all Search services in the given resource group. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/Error.cs b/Samples/3a-literate-swagger/Client/Models/Error.cs index fe76d059f..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/Error.cs +++ b/Samples/3a-literate-swagger/Client/Models/Error.cs @@ -1,54 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class Error - { - /// - /// Initializes a new instance of the Error class. - /// - public Error() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Error class. - /// - public Error(int? code = default(int?), string message = default(string), object details = default(object)) - { - Code = code; - Message = message; - Details = details; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "code")] - public int? Code { get; set; } - - /// - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - /// - /// - [JsonProperty(PropertyName = "details")] - public object Details { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/ErrorDetails.cs b/Samples/3a-literate-swagger/Client/Models/ErrorDetails.cs index 39c94d4f3..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/ErrorDetails.cs +++ b/Samples/3a-literate-swagger/Client/Models/ErrorDetails.cs @@ -1,54 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class ErrorDetails - { - /// - /// Initializes a new instance of the ErrorDetails class. - /// - public ErrorDetails() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ErrorDetails class. - /// - public ErrorDetails(string code = default(string), string target = default(string), string message = default(string)) - { - Code = code; - Target = target; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "code")] - public string Code { get; set; } - - /// - /// - [JsonProperty(PropertyName = "target")] - public string Target { get; set; } - - /// - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/ErrorException.cs b/Samples/3a-literate-swagger/Client/Models/ErrorException.cs index d623929c3..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/ErrorException.cs +++ b/Samples/3a-literate-swagger/Client/Models/ErrorException.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Microsoft.Rest; - - /// - /// Exception thrown for an invalid response with Error information. - /// - public class ErrorException : RestException - { - /// - /// Gets information about the associated HTTP request. - /// - public HttpRequestMessageWrapper Request { get; set; } - - /// - /// Gets information about the associated HTTP response. - /// - public HttpResponseMessageWrapper Response { get; set; } - - /// - /// Gets or sets the body object. - /// - public Error Body { get; set; } - - /// - /// Initializes a new instance of the ErrorException class. - /// - public ErrorException() - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - public ErrorException(string message) - : this(message, null) - { - } - - /// - /// Initializes a new instance of the ErrorException class. - /// - /// The exception message. - /// Inner exception. - public ErrorException(string message, System.Exception innerException) - : base(message, innerException) - { - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/ListQueryKeysResult.cs b/Samples/3a-literate-swagger/Client/Models/ListQueryKeysResult.cs index 5a4a6fedc..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/ListQueryKeysResult.cs +++ b/Samples/3a-literate-swagger/Client/Models/ListQueryKeysResult.cs @@ -1,54 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response containing the query API keys for a given Azure Search - /// service. - /// - public partial class ListQueryKeysResult - { - /// - /// Initializes a new instance of the ListQueryKeysResult class. - /// - public ListQueryKeysResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ListQueryKeysResult class. - /// - /// > Again, shorthand for `@.properties.value` - /// - /// The query keys for the Azure Search service. - public ListQueryKeysResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets &gt; Again, shorthand for `@.properties.value` - /// - /// The query keys for the Azure Search service. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/QueryKey.cs b/Samples/3a-literate-swagger/Client/Models/QueryKey.cs index 8fab48cf2..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/QueryKey.cs +++ b/Samples/3a-literate-swagger/Client/Models/QueryKey.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes an API key for a given Azure Search service that has - /// permissions for query operations only. - /// - public partial class QueryKey - { - /// - /// Initializes a new instance of the QueryKey class. - /// - public QueryKey() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the QueryKey class. - /// - /// The name of the query API key; may be - /// empty. - /// The value of the query API key. - public QueryKey(string name = default(string), string key = default(string)) - { - Name = name; - Key = key; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the name of the query API key; may be empty. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets the value of the query API key. - /// - [JsonProperty(PropertyName = "key")] - public string Key { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/SearchServiceCreateOrUpdateParameters.cs b/Samples/3a-literate-swagger/Client/Models/SearchServiceCreateOrUpdateParameters.cs index 93548f60f..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/SearchServiceCreateOrUpdateParameters.cs +++ b/Samples/3a-literate-swagger/Client/Models/SearchServiceCreateOrUpdateParameters.cs @@ -1,83 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Properties that describe an Azure Search service. - /// - public partial class SearchServiceCreateOrUpdateParameters - { - /// - /// Initializes a new instance of the - /// SearchServiceCreateOrUpdateParameters class. - /// - public SearchServiceCreateOrUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// SearchServiceCreateOrUpdateParameters class. - /// - /// The geographic location of the Search - /// service. - /// Tags to help categorize the Search service in - /// the Azure Portal. - /// Properties of the Search service. - public SearchServiceCreateOrUpdateParameters(string location = default(string), IDictionary tags = default(IDictionary), SearchServiceProperties properties = default(SearchServiceProperties)) - { - Location = location; - Tags = tags; - Properties = properties; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the geographic location of the Search service. - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets tags to help categorize the Search service in the - /// Azure Portal. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets properties of the Search service. - /// - [JsonProperty(PropertyName = "properties")] - public SearchServiceProperties Properties { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Properties != null) - { - Properties.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/SearchServiceListResult.cs b/Samples/3a-literate-swagger/Client/Models/SearchServiceListResult.cs index ef5848c84..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/SearchServiceListResult.cs +++ b/Samples/3a-literate-swagger/Client/Models/SearchServiceListResult.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// > Shorthand for `@.definitions.SearchServiceListResult` which equals - /// `$.definitions.SearchServiceListResult` since no super headings change - /// the current scope. - /// - /// Response containing a list of Azure Search services for a given - /// resource group. - /// - public partial class SearchServiceListResult - { - /// - /// Initializes a new instance of the SearchServiceListResult class. - /// - public SearchServiceListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SearchServiceListResult class. - /// - /// The Search services in the resource - /// group. - public SearchServiceListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the Search services in the resource group. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/SearchServiceProperties.cs b/Samples/3a-literate-swagger/Client/Models/SearchServiceProperties.cs index 542ff6230..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/SearchServiceProperties.cs +++ b/Samples/3a-literate-swagger/Client/Models/SearchServiceProperties.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Defines properties of an Azure Search service that can be modified. - /// - public partial class SearchServiceProperties - { - /// - /// Initializes a new instance of the SearchServiceProperties class. - /// - public SearchServiceProperties() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SearchServiceProperties class. - /// - /// The number of replicas in the Search - /// service. - /// The number of partitions in the Search - /// service; if specified, it can be 1, 2, 3, 4, 6, or 12. - public SearchServiceProperties(int? replicaCount = default(int?), int? partitionCount = default(int?)) - { - ReplicaCount = replicaCount; - PartitionCount = partitionCount; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the number of replicas in the Search service. - /// - [JsonProperty(PropertyName = "replicaCount")] - public int? ReplicaCount { get; set; } - - /// - /// Gets or sets the number of partitions in the Search service; if - /// specified, it can be 1, 2, 3, 4, 6, or 12. - /// - [JsonProperty(PropertyName = "partitionCount")] - public int? PartitionCount { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (ReplicaCount > 6) - { - throw new ValidationException(ValidationRules.InclusiveMaximum, "ReplicaCount", 6); - } - if (ReplicaCount < 1) - { - throw new ValidationException(ValidationRules.InclusiveMinimum, "ReplicaCount", 1); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/Models/SearchServiceResource.cs b/Samples/3a-literate-swagger/Client/Models/SearchServiceResource.cs index 9ccd87777..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/Models/SearchServiceResource.cs +++ b/Samples/3a-literate-swagger/Client/Models/SearchServiceResource.cs @@ -1,77 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Describes an Azure Search service and its current state. - /// - public partial class SearchServiceResource - { - /// - /// Initializes a new instance of the SearchServiceResource class. - /// - public SearchServiceResource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SearchServiceResource class. - /// - /// The resource Id of the Azure Search - /// service. - /// The name of the Search service. - /// The geographic location of the Search - /// service. - /// Tags to help categorize the Search service in - /// the Azure Portal. - public SearchServiceResource(string id = default(string), string name = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the resource Id of the Azure Search service. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets or sets the name of the Search service. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the geographic location of the Search service. - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets tags to help categorize the Search service in the - /// Azure Portal. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/QueryKeysOperations.cs b/Samples/3a-literate-swagger/Client/QueryKeysOperations.cs index 43fb357a5..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/QueryKeysOperations.cs +++ b/Samples/3a-literate-swagger/Client/QueryKeysOperations.cs @@ -1,245 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// QueryKeysOperations operations. - /// - internal partial class QueryKeysOperations : IServiceOperations, IQueryKeysOperations - { - /// - /// Initializes a new instance of the QueryKeysOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal QueryKeysOperations(SearchManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SearchManagementClient - /// - public SearchManagementClient Client { get; private set; } - - /// - /// > `#QueryKeys_List` searches for an object that has a string property - /// containing "QueryKeys_List". - /// - /// Returns the list of query API keys for the given Azure Search service. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(string resourceGroupName, string serviceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (serviceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "serviceName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("serviceName", serviceName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{serviceName}/listQueryKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{serviceName}", System.Uri.EscapeDataString(serviceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/QueryKeysOperationsExtensions.cs b/Samples/3a-literate-swagger/Client/QueryKeysOperationsExtensions.cs index da75f3681..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/QueryKeysOperationsExtensions.cs +++ b/Samples/3a-literate-swagger/Client/QueryKeysOperationsExtensions.cs @@ -1,69 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for QueryKeysOperations. - /// - public static partial class QueryKeysOperationsExtensions - { - /// - /// > `#QueryKeys_List` searches for an object that has a string property - /// containing "QueryKeys_List". - /// - /// Returns the list of query API keys for the given Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - public static ListQueryKeysResult List(this IQueryKeysOperations operations, string resourceGroupName, string serviceName) - { - return operations.ListAsync(resourceGroupName, serviceName).GetAwaiter().GetResult(); - } - - /// - /// > `#QueryKeys_List` searches for an object that has a string property - /// containing "QueryKeys_List". - /// - /// Returns the list of query API keys for the given Azure Search service. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IQueryKeysOperations operations, string resourceGroupName, string serviceName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, serviceName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/SearchManagementClient.cs b/Samples/3a-literate-swagger/Client/SearchManagementClient.cs index 30fb387bf..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/SearchManagementClient.cs +++ b/Samples/3a-literate-swagger/Client/SearchManagementClient.cs @@ -1,325 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - - /// - /// > the above JSON query pushes this markdown section into node - /// `$.info.description` of the OpenAPI definition. - /// - /// This client that can be used to manage Azure Search services and API - /// keys. - /// - public partial class SearchManagementClient : ServiceClient, ISearchManagementClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. - /// The subscription ID forms part of the URI for every service call. - /// - public string SubscriptionId { get; set; } - - /// - /// The client API version. - /// - public string ApiVersion { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Gets the IQueryKeysOperations. - /// - public virtual IQueryKeysOperations QueryKeys { get; private set; } - - /// - /// Gets the IServicesOperations. - /// - public virtual IServicesOperations Services { get; private set; } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected SearchManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected SearchManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected SearchManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected SearchManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SearchManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SearchManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SearchManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the SearchManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SearchManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - QueryKeys = new QueryKeysOperations(this); - Services = new ServicesOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2015-02-28"; - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/ServicesOperations.cs b/Samples/3a-literate-swagger/Client/ServicesOperations.cs index 914b5d6a6..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/ServicesOperations.cs +++ b/Samples/3a-literate-swagger/Client/ServicesOperations.cs @@ -1,635 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ServicesOperations operations. - /// - internal partial class ServicesOperations : IServiceOperations, IServicesOperations - { - /// - /// Initializes a new instance of the ServicesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ServicesOperations(SearchManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SearchManagementClient - /// - public SearchManagementClient Client { get; private set; } - - /// - /// Creates or updates a Search service in the given resource group. - /// If the Search service already exists, all properties will be updated with - /// the given values. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The properties to set or update on the Search service. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serviceName, SearchServiceCreateOrUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (serviceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "serviceName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("serviceName", serviceName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{serviceName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{serviceName}", System.Uri.EscapeDataString(serviceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes a Search service in the given resource group, along with its - /// associated resources. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serviceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (serviceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "serviceName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("serviceName", serviceName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{serviceName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{serviceName}", System.Uri.EscapeDataString(serviceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204 && (int)_statusCode != 404) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns a list of all Search services in the given resource group. - /// - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Error _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3a-literate-swagger/Client/ServicesOperationsExtensions.cs b/Samples/3a-literate-swagger/Client/ServicesOperationsExtensions.cs index 4170a08ec..9d6cafc2c 100644 --- a/Samples/3a-literate-swagger/Client/ServicesOperationsExtensions.cs +++ b/Samples/3a-literate-swagger/Client/ServicesOperationsExtensions.cs @@ -1,150 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Swagger -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ServicesOperations. - /// - public static partial class ServicesOperationsExtensions - { - /// - /// Creates or updates a Search service in the given resource group. - /// If the Search service already exists, all properties will be updated with - /// the given values. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The properties to set or update on the Search service. - /// - public static SearchServiceResource CreateOrUpdate(this IServicesOperations operations, string resourceGroupName, string serviceName, SearchServiceCreateOrUpdateParameters parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, serviceName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a Search service in the given resource group. - /// If the Search service already exists, all properties will be updated with - /// the given values. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The properties to set or update on the Search service. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IServicesOperations operations, string resourceGroupName, string serviceName, SearchServiceCreateOrUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serviceName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a Search service in the given resource group, along with its - /// associated resources. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - public static void Delete(this IServicesOperations operations, string resourceGroupName, string serviceName) - { - operations.DeleteAsync(resourceGroupName, serviceName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a Search service in the given resource group, along with its - /// associated resources. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The name of the Search service to operate on. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IServicesOperations operations, string resourceGroupName, string serviceName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serviceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns a list of all Search services in the given resource group. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - public static SearchServiceListResult List(this IServicesOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Returns a list of all Search services in the given resource group. - /// - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the current subscription. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IServicesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperations.cs b/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperations.cs index 83cfa0977..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperations.cs +++ b/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperations.cs @@ -1,1717 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CheckNameAvailabilityOperations operations. - /// - internal partial class CheckNameAvailabilityOperations : IServiceOperations, ICheckNameAvailabilityOperations - { - /// - /// Initializes a new instance of the CheckNameAvailabilityOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal CheckNameAvailabilityOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Checks that the account name has sufficient cowbell (in order to prevent - /// fevers). - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - accountName.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. Make sure you add that extra cowbell. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertyWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperty", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (regenerateKey == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "regenerateKey"); - } - if (regenerateKey != null) - { - regenerateKey.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperationsExtensions.cs b/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperationsExtensions.cs index b6a091faa..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperationsExtensions.cs +++ b/Samples/3b-custom-transformations/Client/CheckNameAvailabilityOperationsExtensions.cs @@ -1,444 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CheckNameAvailabilityOperations. - /// - public static partial class CheckNameAvailabilityOperationsExtensions - { - /// - /// Checks that the account name has sufficient cowbell (in order to prevent - /// fevers). - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static CheckNameAvailabilityResult CheckNameAvailability(this ICheckNameAvailabilityOperations operations, StorageAccountCheckNameAvailabilityParameters accountName) - { - return operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult(); - } - - /// - /// Checks that the account name has sufficient cowbell (in order to prevent - /// fevers). - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this ICheckNameAvailabilityOperations operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. Make sure you add that extra cowbell. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount Create(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. Make sure you add that extra cowbell. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static void Delete(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName) - { - operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static StorageAccount GetProperty(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName) - { - return operations.GetPropertyAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertyAsync(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertyWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - public static StorageAccount Update(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - public static StorageAccountKeys ListKeys(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName) - { - return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - public static IEnumerable List(this ICheckNameAvailabilityOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ICheckNameAvailabilityOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - public static IEnumerable ListByResourceGroup(this ICheckNameAvailabilityOperations operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByResourceGroupAsync(this ICheckNameAvailabilityOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - public static StorageAccountKeys RegenerateKey(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey) - { - return operations.RegenerateKeyAsync(resourceGroupName, accountName, regenerateKey).GetAwaiter().GetResult(); - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this ICheckNameAvailabilityOperations operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, regenerateKey, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/ICheckNameAvailabilityOperations.cs b/Samples/3b-custom-transformations/Client/ICheckNameAvailabilityOperations.cs index 50ea549ba..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/ICheckNameAvailabilityOperations.cs +++ b/Samples/3b-custom-transformations/Client/ICheckNameAvailabilityOperations.cs @@ -1,281 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CheckNameAvailabilityOperations operations. - /// - public partial interface ICheckNameAvailabilityOperations - { - /// - /// Checks that the account name has sufficient cowbell (in order to - /// prevent fevers). - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. Make sure - /// you add that extra cowbell. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertyWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one - /// property can be changed at a time using this API. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 - /// for the default keys - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/IStorageAccounts.cs b/Samples/3b-custom-transformations/Client/IStorageAccounts.cs index e92d953b4..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/IStorageAccounts.cs +++ b/Samples/3b-custom-transformations/Client/IStorageAccounts.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial interface IStorageAccounts - { - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. Make sure - /// you add that extra cowbell. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/IStorageManagementClient.cs b/Samples/3b-custom-transformations/Client/IStorageManagementClient.cs index 3b0dc8ae4..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/IStorageManagementClient.cs +++ b/Samples/3b-custom-transformations/Client/IStorageManagementClient.cs @@ -1,85 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - - /// - /// The Storage Management Client. - /// - public partial interface IStorageManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - string ApiVersion { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// Gets the ICheckNameAvailabilityOperations. - /// - ICheckNameAvailabilityOperations CheckNameAvailability { get; } - - /// - /// Gets the IUsagesOperations. - /// - IUsagesOperations Usages { get; } - - /// - /// Gets the IStorageAccounts. - /// - IStorageAccounts StorageAccounts { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/IUsagesOperations.cs b/Samples/3b-custom-transformations/Client/IUsagesOperations.cs index 9124421e9..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/IUsagesOperations.cs +++ b/Samples/3b-custom-transformations/Client/IUsagesOperations.cs @@ -1,43 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsagesOperations operations. - /// - public partial interface IUsagesOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/AccountStatus.cs b/Samples/3b-custom-transformations/Client/Models/AccountStatus.cs index add75dbff..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/AccountStatus.cs +++ b/Samples/3b-custom-transformations/Client/Models/AccountStatus.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/AccountType.cs b/Samples/3b-custom-transformations/Client/Models/AccountType.cs index 927636470..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/AccountType.cs +++ b/Samples/3b-custom-transformations/Client/Models/AccountType.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/CheckNameAvailabilityResult.cs b/Samples/3b-custom-transformations/Client/Models/CheckNameAvailabilityResult.cs index 3cd5b4328..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/CheckNameAvailabilityResult.cs +++ b/Samples/3b-custom-transformations/Client/Models/CheckNameAvailabilityResult.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/CustomDomain.cs b/Samples/3b-custom-transformations/Client/Models/CustomDomain.cs index 7e45930f6..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/CustomDomain.cs +++ b/Samples/3b-custom-transformations/Client/Models/CustomDomain.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/Endpoints.cs b/Samples/3b-custom-transformations/Client/Models/Endpoints.cs index cde486b00..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/Endpoints.cs +++ b/Samples/3b-custom-transformations/Client/Models/Endpoints.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/Page.cs b/Samples/3b-custom-transformations/Client/Models/Page.cs index f0225b4df..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/Page.cs +++ b/Samples/3b-custom-transformations/Client/Models/Page.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - - /// - /// Defines a page in Azure responses. - /// - /// Type of the page content items - [JsonObject] - public class Page : IPage - { - /// - /// Gets the link to the next page. - /// - [JsonProperty("")] - public string NextPageLink { get; private set; } - - [JsonProperty("value")] - private IList Items{ get; set; } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/ProvisioningState.cs b/Samples/3b-custom-transformations/Client/Models/ProvisioningState.cs index b5b85bac3..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/ProvisioningState.cs +++ b/Samples/3b-custom-transformations/Client/Models/ProvisioningState.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/Reason.cs b/Samples/3b-custom-transformations/Client/Models/Reason.cs index ecaf08ffd..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/Reason.cs +++ b/Samples/3b-custom-transformations/Client/Models/Reason.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/Resource.cs b/Samples/3b-custom-transformations/Client/Models/Resource.cs index eef720b30..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/Resource.cs +++ b/Samples/3b-custom-transformations/Client/Models/Resource.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource : IResource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/StorageAccount.cs b/Samples/3b-custom-transformations/Client/Models/StorageAccount.cs index ab7cb2a5a..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/StorageAccount.cs +++ b/Samples/3b-custom-transformations/Client/Models/StorageAccount.cs @@ -1,198 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/3b-custom-transformations/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs index 4c0b6121c..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/3b-custom-transformations/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/StorageAccountCreateParameters.cs b/Samples/3b-custom-transformations/Client/Models/StorageAccountCreateParameters.cs index 261f57172..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/StorageAccountCreateParameters.cs +++ b/Samples/3b-custom-transformations/Client/Models/StorageAccountCreateParameters.cs @@ -1,88 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/StorageAccountKeys.cs b/Samples/3b-custom-transformations/Client/Models/StorageAccountKeys.cs index 44c01154f..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/StorageAccountKeys.cs +++ b/Samples/3b-custom-transformations/Client/Models/StorageAccountKeys.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/3b-custom-transformations/Client/Models/StorageAccountRegenerateKeyParameters.cs index 8f04bcd7a..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/3b-custom-transformations/Client/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/StorageAccountUpdateParameters.cs b/Samples/3b-custom-transformations/Client/Models/StorageAccountUpdateParameters.cs index 937b4acc9..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/StorageAccountUpdateParameters.cs +++ b/Samples/3b-custom-transformations/Client/Models/StorageAccountUpdateParameters.cs @@ -1,100 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/Usage.cs b/Samples/3b-custom-transformations/Client/Models/Usage.cs index 321e7629a..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/Usage.cs +++ b/Samples/3b-custom-transformations/Client/Models/Usage.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// DESCRIBES STORAGE RESOURCE USAGE. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/UsageName.cs b/Samples/3b-custom-transformations/Client/Models/UsageName.cs index 8fa9f973f..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/UsageName.cs +++ b/Samples/3b-custom-transformations/Client/Models/UsageName.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/Models/UsageUnit.cs b/Samples/3b-custom-transformations/Client/Models/UsageUnit.cs index cf012fd42..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/Models/UsageUnit.cs +++ b/Samples/3b-custom-transformations/Client/Models/UsageUnit.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/StorageAccounts.cs b/Samples/3b-custom-transformations/Client/StorageAccounts.cs index 40cd05046..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/StorageAccounts.cs +++ b/Samples/3b-custom-transformations/Client/StorageAccounts.cs @@ -1,281 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - internal partial class StorageAccounts : IServiceOperations, IStorageAccounts - { - /// - /// Initializes a new instance of the StorageAccounts class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal StorageAccounts(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. Make sure you add that extra cowbell. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/StorageAccountsExtensions.cs b/Samples/3b-custom-transformations/Client/StorageAccountsExtensions.cs index a4322db37..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/StorageAccountsExtensions.cs +++ b/Samples/3b-custom-transformations/Client/StorageAccountsExtensions.cs @@ -1,79 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccounts. - /// - public static partial class StorageAccountsExtensions - { - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. Make sure you add that extra cowbell. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount BeginCreate(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.BeginCreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. Make sure you add that extra cowbell. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/StorageManagementClient.cs b/Samples/3b-custom-transformations/Client/StorageManagementClient.cs index ce28424cd..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/StorageManagementClient.cs +++ b/Samples/3b-custom-transformations/Client/StorageManagementClient.cs @@ -1,329 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - - /// - /// The Storage Management Client. - /// - public partial class StorageManagementClient : ServiceClient, IStorageManagementClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - public string ApiVersion { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Gets the ICheckNameAvailabilityOperations. - /// - public virtual ICheckNameAvailabilityOperations CheckNameAvailability { get; private set; } - - /// - /// Gets the IUsagesOperations. - /// - public virtual IUsagesOperations Usages { get; private set; } - - /// - /// Gets the IStorageAccounts. - /// - public virtual IStorageAccounts StorageAccounts { get; private set; } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - CheckNameAvailability = new CheckNameAvailabilityOperations(this); - Usages = new UsagesOperations(this); - StorageAccounts = new StorageAccounts(this); - BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2015-06-15"; - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/UsagesOperations.cs b/Samples/3b-custom-transformations/Client/UsagesOperations.cs index 0be746cdf..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/UsagesOperations.cs +++ b/Samples/3b-custom-transformations/Client/UsagesOperations.cs @@ -1,229 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsagesOperations operations. - /// - internal partial class UsagesOperations : IServiceOperations, IUsagesOperations - { - /// - /// Initializes a new instance of the UsagesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal UsagesOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3b-custom-transformations/Client/UsagesOperationsExtensions.cs b/Samples/3b-custom-transformations/Client/UsagesOperationsExtensions.cs index 4c195f081..9d6cafc2c 100644 --- a/Samples/3b-custom-transformations/Client/UsagesOperationsExtensions.cs +++ b/Samples/3b-custom-transformations/Client/UsagesOperationsExtensions.cs @@ -1,53 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsagesOperations. - /// - public static partial class UsagesOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IEnumerable List(this IUsagesOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IUsagesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/IStorageAccounts.cs b/Samples/3c-guards/Client/IStorageAccounts.cs index e821ba839..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/IStorageAccounts.cs +++ b/Samples/3c-guards/Client/IStorageAccounts.cs @@ -1,278 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial interface IStorageAccounts - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one - /// property can be changed at a time using this API. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 - /// for the default keys - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/IStorageManagementClient.cs b/Samples/3c-guards/Client/IStorageManagementClient.cs index 361f9fcad..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/IStorageManagementClient.cs +++ b/Samples/3c-guards/Client/IStorageManagementClient.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Models; - using Newtonsoft.Json; - - /// - /// The Storage Management Client. - /// - public partial interface IStorageManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - string ApiVersion { get; set; } - - - /// - /// Gets the IStorageAccounts. - /// - IStorageAccounts StorageAccounts { get; } - - /// - /// Gets the IUsageOperations. - /// - IUsageOperations Usage { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/IUsageOperations.cs b/Samples/3c-guards/Client/IUsageOperations.cs index 1e96fecd4..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/IUsageOperations.cs +++ b/Samples/3c-guards/Client/IUsageOperations.cs @@ -1,42 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial interface IUsageOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/AccountStatus.cs b/Samples/3c-guards/Client/Models/AccountStatus.cs index add75dbff..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/AccountStatus.cs +++ b/Samples/3c-guards/Client/Models/AccountStatus.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/AccountType.cs b/Samples/3c-guards/Client/Models/AccountType.cs index 927636470..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/AccountType.cs +++ b/Samples/3c-guards/Client/Models/AccountType.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/CheckNameAvailabilityResult.cs b/Samples/3c-guards/Client/Models/CheckNameAvailabilityResult.cs index 3cd5b4328..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/CheckNameAvailabilityResult.cs +++ b/Samples/3c-guards/Client/Models/CheckNameAvailabilityResult.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/CustomDomain.cs b/Samples/3c-guards/Client/Models/CustomDomain.cs index 7e45930f6..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/CustomDomain.cs +++ b/Samples/3c-guards/Client/Models/CustomDomain.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/Endpoints.cs b/Samples/3c-guards/Client/Models/Endpoints.cs index cde486b00..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/Endpoints.cs +++ b/Samples/3c-guards/Client/Models/Endpoints.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/ProvisioningState.cs b/Samples/3c-guards/Client/Models/ProvisioningState.cs index b5b85bac3..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/ProvisioningState.cs +++ b/Samples/3c-guards/Client/Models/ProvisioningState.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/Reason.cs b/Samples/3c-guards/Client/Models/Reason.cs index ecaf08ffd..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/Reason.cs +++ b/Samples/3c-guards/Client/Models/Reason.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/Resource.cs b/Samples/3c-guards/Client/Models/Resource.cs index 9074a464c..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/Resource.cs +++ b/Samples/3c-guards/Client/Models/Resource.cs @@ -1,78 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/StorageAccount.cs b/Samples/3c-guards/Client/Models/StorageAccount.cs index ab7cb2a5a..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/StorageAccount.cs +++ b/Samples/3c-guards/Client/Models/StorageAccount.cs @@ -1,198 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/3c-guards/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs index 4c0b6121c..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/3c-guards/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/StorageAccountCreateParameters.cs b/Samples/3c-guards/Client/Models/StorageAccountCreateParameters.cs index 4338b6c4a..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/StorageAccountCreateParameters.cs +++ b/Samples/3c-guards/Client/Models/StorageAccountCreateParameters.cs @@ -1,87 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/StorageAccountKeys.cs b/Samples/3c-guards/Client/Models/StorageAccountKeys.cs index 44c01154f..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/StorageAccountKeys.cs +++ b/Samples/3c-guards/Client/Models/StorageAccountKeys.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/StorageAccountListResult.cs b/Samples/3c-guards/Client/Models/StorageAccountListResult.cs index bfcdd6042..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/StorageAccountListResult.cs +++ b/Samples/3c-guards/Client/Models/StorageAccountListResult.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The list storage accounts operation response. - /// - public partial class StorageAccountListResult - { - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - public StorageAccountListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - /// Gets the list of storage accounts and their - /// properties. - public StorageAccountListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of storage accounts and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/3c-guards/Client/Models/StorageAccountRegenerateKeyParameters.cs index 8f04bcd7a..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/3c-guards/Client/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/StorageAccountUpdateParameters.cs b/Samples/3c-guards/Client/Models/StorageAccountUpdateParameters.cs index 5368388b0..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/StorageAccountUpdateParameters.cs +++ b/Samples/3c-guards/Client/Models/StorageAccountUpdateParameters.cs @@ -1,99 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/Usage.cs b/Samples/3c-guards/Client/Models/Usage.cs index cc75396a7..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/Usage.cs +++ b/Samples/3c-guards/Client/Models/Usage.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes Storage Resource Usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/UsageListResult.cs b/Samples/3c-guards/Client/Models/UsageListResult.cs index 1e884f4d1..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/UsageListResult.cs +++ b/Samples/3c-guards/Client/Models/UsageListResult.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List Usages operation response. - /// - public partial class UsageListResult - { - /// - /// Initializes a new instance of the UsageListResult class. - /// - public UsageListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageListResult class. - /// - /// Gets or sets the list Storage Resource - /// Usages. - public UsageListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the list Storage Resource Usages. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/UsageName.cs b/Samples/3c-guards/Client/Models/UsageName.cs index 8fa9f973f..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/UsageName.cs +++ b/Samples/3c-guards/Client/Models/UsageName.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/Models/UsageUnit.cs b/Samples/3c-guards/Client/Models/UsageUnit.cs index cf012fd42..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/Models/UsageUnit.cs +++ b/Samples/3c-guards/Client/Models/UsageUnit.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/StorageAccounts.cs b/Samples/3c-guards/Client/StorageAccounts.cs index a80fb5faa..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/StorageAccounts.cs +++ b/Samples/3c-guards/Client/StorageAccounts.cs @@ -1,1609 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial class StorageAccounts : IServiceOperations, IStorageAccounts - { - /// - /// Initializes a new instance of the StorageAccounts class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageAccounts(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - accountName.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperties", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (regenerateKey == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "regenerateKey"); - } - if (regenerateKey != null) - { - regenerateKey.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/StorageAccountsExtensions.cs b/Samples/3c-guards/Client/StorageAccountsExtensions.cs index bfc1c0dc7..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/StorageAccountsExtensions.cs +++ b/Samples/3c-guards/Client/StorageAccountsExtensions.cs @@ -1,438 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccounts. - /// - public static partial class StorageAccountsExtensions - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName) - { - return operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult(); - } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount Create(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static void Delete(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static StorageAccount GetProperties(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.GetPropertiesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertiesAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - public static StorageAccount Update(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - public static StorageAccountKeys ListKeys(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - public static StorageAccountListResult List(this IStorageAccounts operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IStorageAccounts operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - public static StorageAccountListResult ListByResourceGroup(this IStorageAccounts operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task ListByResourceGroupAsync(this IStorageAccounts operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - public static StorageAccountKeys RegenerateKey(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey) - { - return operations.RegenerateKeyAsync(resourceGroupName, accountName, regenerateKey).GetAwaiter().GetResult(); - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, regenerateKey, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/StorageManagementClient.cs b/Samples/3c-guards/Client/StorageManagementClient.cs index 711e6ddf9..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/StorageManagementClient.cs +++ b/Samples/3c-guards/Client/StorageManagementClient.cs @@ -1,172 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// The Storage Management Client. - /// - public partial class StorageManagementClient : ServiceClient, IStorageManagementClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - public string ApiVersion { get; set; } - - /// - /// Gets the IStorageAccounts. - /// - public virtual IStorageAccounts StorageAccounts { get; private set; } - - /// - /// Gets the IUsageOperations. - /// - public virtual IUsageOperations Usage { get; private set; } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public StorageManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public StorageManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - StorageAccounts = new StorageAccounts(this); - Usage = new UsageOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/UsageOperations.cs b/Samples/3c-guards/Client/UsageOperations.cs index a07be839c..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/UsageOperations.cs +++ b/Samples/3c-guards/Client/UsageOperations.cs @@ -1,194 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial class UsageOperations : IServiceOperations, IUsageOperations - { - /// - /// Initializes a new instance of the UsageOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public UsageOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/Client/UsageOperationsExtensions.cs b/Samples/3c-guards/Client/UsageOperationsExtensions.cs index f87f4f7df..9d6cafc2c 100644 --- a/Samples/3c-guards/Client/UsageOperationsExtensions.cs +++ b/Samples/3c-guards/Client/UsageOperationsExtensions.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsageOperations. - /// - public static partial class UsageOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - public static UsageListResult List(this IUsageOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IUsageOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/StorageAccounts.java b/Samples/3c-guards/OtherClient/StorageAccounts.java index 8cf2e1f00..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/StorageAccounts.java +++ b/Samples/3c-guards/OtherClient/StorageAccounts.java @@ -1,411 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import .models.CheckNameAvailabilityResult; -import .models.StorageAccount; -import .models.StorageAccountCheckNameAvailabilityParameters; -import .models.StorageAccountCreateParameters; -import .models.StorageAccountKeys; -import .models.StorageAccountListResult; -import .models.StorageAccountRegenerateKeyParameters; -import .models.StorageAccountUpdateParameters; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in StorageAccounts. - */ -public interface StorageAccounts { - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the CheckNameAvailabilityResult object if successful. - */ - CheckNameAvailabilityResult checkNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, final ServiceCallback serviceCallback); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - Observable checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - Observable> checkNameAvailabilityWithServiceResponseAsync(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void delete(String resourceGroupName, String accountName); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture deleteAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable deleteAsync(String resourceGroupName, String accountName); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount getProperties(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture getPropertiesAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable getPropertiesAsync(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> getPropertiesWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters, final ServiceCallback serviceCallback); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - StorageAccountKeys listKeys(String resourceGroupName, String accountName); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable listKeysAsync(String resourceGroupName, String accountName); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - StorageAccountListResult list(); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listAsync(final ServiceCallback serviceCallback); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable listAsync(); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable> listWithServiceResponseAsync(); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - StorageAccountListResult listByResourceGroup(String resourceGroupName); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listByResourceGroupAsync(String resourceGroupName, final ServiceCallback serviceCallback); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable listByResourceGroupAsync(String resourceGroupName); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable> listByResourceGroupWithServiceResponseAsync(String resourceGroupName); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - StorageAccountKeys regenerateKey(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey, final ServiceCallback serviceCallback); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/StorageManagementClient.java b/Samples/3c-guards/OtherClient/StorageManagementClient.java index 9b02c9499..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/StorageManagementClient.java +++ b/Samples/3c-guards/OtherClient/StorageManagementClient.java @@ -1,69 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import com.microsoft.rest.RestClient; - -/** - * The interface for StorageManagementClient class. - */ -public interface StorageManagementClient { - /** - * Gets the REST client. - * - * @return the {@link RestClient} object. - */ - RestClient restClient(); - - /** - * The default base URL. - */ - String DEFAULT_BASE_URL = "https://management.azure.com"; - - /** - * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. - * - * @return the subscriptionId value. - */ - String subscriptionId(); - - /** - * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. - * - * @param subscriptionId the subscriptionId value. - * @return the service client itself - */ - StorageManagementClient withSubscriptionId(String subscriptionId); - - /** - * Gets Client Api Version.. - * - * @return the apiVersion value. - */ - String apiVersion(); - - /** - * Sets Client Api Version.. - * - * @param apiVersion the apiVersion value. - * @return the service client itself - */ - StorageManagementClient withApiVersion(String apiVersion); - - /** - * Gets the StorageAccounts object to access its operations. - * @return the StorageAccounts object. - */ - StorageAccounts storageAccounts(); - - /** - * Gets the Usages object to access its operations. - * @return the Usages object. - */ - Usages usages(); - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/Usages.java b/Samples/3c-guards/OtherClient/Usages.java index 51d136391..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/Usages.java +++ b/Samples/3c-guards/OtherClient/Usages.java @@ -1,57 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import .models.UsageListResult; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Usages. - */ -public interface Usages { - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the UsageListResult object if successful. - */ - UsageListResult list(); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listAsync(final ServiceCallback serviceCallback); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - Observable listAsync(); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - Observable> listWithServiceResponseAsync(); - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/implementation/StorageAccountsImpl.java b/Samples/3c-guards/OtherClient/implementation/StorageAccountsImpl.java index fadfb694e..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/implementation/StorageAccountsImpl.java +++ b/Samples/3c-guards/OtherClient/implementation/StorageAccountsImpl.java @@ -1,867 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import retrofit2.Retrofit; -import .StorageAccounts; -import .models.CheckNameAvailabilityResult; -import .models.StorageAccount; -import .models.StorageAccountCheckNameAvailabilityParameters; -import .models.StorageAccountCreateParameters; -import .models.StorageAccountKeys; -import .models.StorageAccountListResult; -import .models.StorageAccountRegenerateKeyParameters; -import .models.StorageAccountUpdateParameters; -import com.google.common.reflect.TypeToken; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.Validator; -import java.io.IOException; -import okhttp3.ResponseBody; -import retrofit2.http.Body; -import retrofit2.http.GET; -import retrofit2.http.Headers; -import retrofit2.http.HTTP; -import retrofit2.http.PATCH; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.http.PUT; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in StorageAccounts. - */ -public class StorageAccountsImpl implements StorageAccounts { - /** The Retrofit service to perform REST calls. */ - private StorageAccountsService service; - /** The service client containing this operation class. */ - private StorageManagementClientImpl client; - - /** - * Initializes an instance of StorageAccounts. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public StorageAccountsImpl(Retrofit retrofit, StorageManagementClientImpl client) { - this.service = retrofit.create(StorageAccountsService.class); - this.client = client; - } - - /** - * The interface defining all the services for StorageAccounts to be - * used by Retrofit to perform actually REST calls. - */ - interface StorageAccountsService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts checkNameAvailability" }) - @POST("subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") - Observable> checkNameAvailability(@Path("subscriptionId") String subscriptionId, @Body StorageAccountCheckNameAvailabilityParameters accountName, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts create" }) - @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> create(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountCreateParameters parameters, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts delete" }) - @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", method = "DELETE", hasBody = true) - Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts getProperties" }) - @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> getProperties(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts update" }) - @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountUpdateParameters parameters, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts listKeys" }) - @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") - Observable> listKeys(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts list" }) - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") - Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts listByResourceGroup" }) - @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") - Observable> listByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts regenerateKey" }) - @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") - Observable> regenerateKey(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountRegenerateKeyParameters regenerateKey, @Query("api-version") String apiVersion); - - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the CheckNameAvailabilityResult object if successful. - */ - public CheckNameAvailabilityResult checkNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName) { - return checkNameAvailabilityWithServiceResponseAsync(accountName).toBlocking().single().body(); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(checkNameAvailabilityWithServiceResponseAsync(accountName), serviceCallback); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - public Observable checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName) { - return checkNameAvailabilityWithServiceResponseAsync(accountName).map(new Func1, CheckNameAvailabilityResult>() { - @Override - public CheckNameAvailabilityResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - public Observable> checkNameAvailabilityWithServiceResponseAsync(StorageAccountCheckNameAvailabilityParameters accountName) { - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(accountName); - return service.checkNameAvailability(this.client.subscriptionId(), accountName, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = checkNameAvailabilityDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse checkNameAvailabilityDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body(); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (parameters == null) { - throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(parameters); - return service.create(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse createDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .register(202, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void delete(String resourceGroupName, String accountName) { - deleteWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture deleteAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable deleteAsync(String resourceGroupName, String accountName) { - return deleteWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.delete(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse deleteDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .register(204, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount getProperties(String resourceGroupName, String accountName) { - return getPropertiesWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture getPropertiesAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(getPropertiesWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable getPropertiesAsync(String resourceGroupName, String accountName) { - return getPropertiesWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> getPropertiesWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.getProperties(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getPropertiesDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse getPropertiesDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body(); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (parameters == null) { - throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(parameters); - return service.update(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse updateDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - public StorageAccountKeys listKeys(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listKeysWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable listKeysAsync(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, StorageAccountKeys>() { - @Override - public StorageAccountKeys call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.listKeys(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listKeysDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listKeysDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - public StorageAccountListResult list() { - return listWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listAsync(final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable listAsync() { - return listWithServiceResponseAsync().map(new Func1, StorageAccountListResult>() { - @Override - public StorageAccountListResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable> listWithServiceResponseAsync() { - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.list(this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - public StorageAccountListResult listByResourceGroup(String resourceGroupName) { - return listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body(); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listByResourceGroupAsync(String resourceGroupName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listByResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable listByResourceGroupAsync(String resourceGroupName) { - return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1, StorageAccountListResult>() { - @Override - public StorageAccountListResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable> listByResourceGroupWithServiceResponseAsync(String resourceGroupName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listByResourceGroupDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listByResourceGroupDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - public StorageAccountKeys regenerateKey(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey).toBlocking().single().body(); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey), serviceCallback); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey).map(new Func1, StorageAccountKeys>() { - @Override - public StorageAccountKeys call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (regenerateKey == null) { - throw new IllegalArgumentException("Parameter regenerateKey is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(regenerateKey); - return service.regenerateKey(resourceGroupName, accountName, this.client.subscriptionId(), regenerateKey, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = regenerateKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse regenerateKeyDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/implementation/StorageManagementClientImpl.java b/Samples/3c-guards/OtherClient/implementation/StorageManagementClientImpl.java index 4e34e5f66..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/implementation/StorageManagementClientImpl.java +++ b/Samples/3c-guards/OtherClient/implementation/StorageManagementClientImpl.java @@ -1,148 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import .StorageManagementClient; -import .StorageAccounts; -import .Usages; -import com.microsoft.rest.ServiceClient; -import com.microsoft.rest.RestClient; -import okhttp3.OkHttpClient; -import retrofit2.Retrofit; - -/** - * Initializes a new instance of the StorageManagementClient class. - */ -public class StorageManagementClientImpl extends ServiceClient implements StorageManagementClient { - - /** Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. */ - private String subscriptionId; - - /** - * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - * - * @return the subscriptionId value. - */ - public String subscriptionId() { - return this.subscriptionId; - } - - /** - * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - * - * @param subscriptionId the subscriptionId value. - * @return the service client itself - */ - public StorageManagementClientImpl withSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - return this; - } - - /** Client Api Version. */ - private String apiVersion; - - /** - * Gets Client Api Version. - * - * @return the apiVersion value. - */ - public String apiVersion() { - return this.apiVersion; - } - - /** - * Sets Client Api Version. - * - * @param apiVersion the apiVersion value. - * @return the service client itself - */ - public StorageManagementClientImpl withApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - return this; - } - - /** - * The StorageAccounts object to access its operations. - */ - private StorageAccounts storageAccounts; - - /** - * Gets the StorageAccounts object to access its operations. - * @return the StorageAccounts object. - */ - public StorageAccounts storageAccounts() { - return this.storageAccounts; - } - - /** - * The Usages object to access its operations. - */ - private Usages usages; - - /** - * Gets the Usages object to access its operations. - * @return the Usages object. - */ - public Usages usages() { - return this.usages; - } - - /** - * Initializes an instance of StorageManagementClient client. - */ - public StorageManagementClientImpl() { - this("https://management.azure.com"); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param baseUrl the base URL of the host - */ - public StorageManagementClientImpl(String baseUrl) { - super(baseUrl); - initialize(); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public StorageManagementClientImpl(OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - this("https://management.azure.com", clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param baseUrl the base URL of the host - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public StorageManagementClientImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - super(baseUrl, clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param restClient the REST client containing pre-configured settings - */ - public StorageManagementClientImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - private void initialize() { - this.storageAccounts = new StorageAccountsImpl(retrofit(), this); - this.usages = new UsagesImpl(retrofit(), this); - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/implementation/UsagesImpl.java b/Samples/3c-guards/OtherClient/implementation/UsagesImpl.java index 8b5576b13..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/implementation/UsagesImpl.java +++ b/Samples/3c-guards/OtherClient/implementation/UsagesImpl.java @@ -1,130 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import retrofit2.Retrofit; -import .Usages; -import .models.UsageListResult; -import com.google.common.reflect.TypeToken; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import okhttp3.ResponseBody; -import retrofit2.http.GET; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Usages. - */ -public class UsagesImpl implements Usages { - /** The Retrofit service to perform REST calls. */ - private UsagesService service; - /** The service client containing this operation class. */ - private StorageManagementClientImpl client; - - /** - * Initializes an instance of Usages. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public UsagesImpl(Retrofit retrofit, StorageManagementClientImpl client) { - this.service = retrofit.create(UsagesService.class); - this.client = client; - } - - /** - * The interface defining all the services for Usages to be - * used by Retrofit to perform actually REST calls. - */ - interface UsagesService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .Usages list" }) - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") - Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the UsageListResult object if successful. - */ - public UsageListResult list() { - return listWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listAsync(final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - public Observable listAsync() { - return listWithServiceResponseAsync().map(new Func1, UsageListResult>() { - @Override - public UsageListResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - public Observable> listWithServiceResponseAsync() { - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.list(this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/implementation/package-info.java b/Samples/3c-guards/OtherClient/implementation/package-info.java index 0c19b9bfc..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/implementation/package-info.java +++ b/Samples/3c-guards/OtherClient/implementation/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage.implementation; +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/AccountStatus.java b/Samples/3c-guards/OtherClient/models/AccountStatus.java index 20ee2a21e..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/AccountStatus.java +++ b/Samples/3c-guards/OtherClient/models/AccountStatus.java @@ -1,51 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for AccountStatus. - */ -public enum AccountStatus { - /** Enum value Available. */ - AVAILABLE("Available"), - - /** Enum value Unavailable. */ - UNAVAILABLE("Unavailable"); - - /** The actual serialized value for a AccountStatus instance. */ - private String value; - - AccountStatus(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AccountStatus instance. - * - * @param value the serialized value to parse. - * @return the parsed AccountStatus object, or null if unable to parse. - */ - @JsonCreator - public static AccountStatus fromString(String value) { - AccountStatus[] items = AccountStatus.values(); - for (AccountStatus item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/AccountType.java b/Samples/3c-guards/OtherClient/models/AccountType.java index d01ec02b5..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/AccountType.java +++ b/Samples/3c-guards/OtherClient/models/AccountType.java @@ -1,60 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for AccountType. - */ -public enum AccountType { - /** Enum value Standard_LRS. */ - STANDARD_LRS("Standard_LRS"), - - /** Enum value Standard_ZRS. */ - STANDARD_ZRS("Standard_ZRS"), - - /** Enum value Standard_GRS. */ - STANDARD_GRS("Standard_GRS"), - - /** Enum value Standard_RAGRS. */ - STANDARD_RAGRS("Standard_RAGRS"), - - /** Enum value Premium_LRS. */ - PREMIUM_LRS("Premium_LRS"); - - /** The actual serialized value for a AccountType instance. */ - private String value; - - AccountType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AccountType instance. - * - * @param value the serialized value to parse. - * @return the parsed AccountType object, or null if unable to parse. - */ - @JsonCreator - public static AccountType fromString(String value) { - AccountType[] items = AccountType.values(); - for (AccountType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/CheckNameAvailabilityResult.java b/Samples/3c-guards/OtherClient/models/CheckNameAvailabilityResult.java index 5a0f4514a..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/CheckNameAvailabilityResult.java +++ b/Samples/3c-guards/OtherClient/models/CheckNameAvailabilityResult.java @@ -1,97 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The CheckNameAvailability operation response. - */ -public class CheckNameAvailabilityResult { - /** - * Gets a boolean value that indicates whether the name is available for - * you to use. If true, the name is available. If false, the name has - * already been taken or invalid and cannot be used. - */ - @JsonProperty(value = "nameAvailable") - private Boolean nameAvailable; - - /** - * Gets the reason that a storage account name could not be used. The - * Reason element is only returned if NameAvailable is false. Possible - * values include: 'AccountNameInvalid', 'AlreadyExists'. - */ - @JsonProperty(value = "reason") - private Reason reason; - - /** - * Gets an error message explaining the Reason value in more detail. - */ - @JsonProperty(value = "message") - private String message; - - /** - * Get the nameAvailable value. - * - * @return the nameAvailable value - */ - public Boolean nameAvailable() { - return this.nameAvailable; - } - - /** - * Set the nameAvailable value. - * - * @param nameAvailable the nameAvailable value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withNameAvailable(Boolean nameAvailable) { - this.nameAvailable = nameAvailable; - return this; - } - - /** - * Get the reason value. - * - * @return the reason value - */ - public Reason reason() { - return this.reason; - } - - /** - * Set the reason value. - * - * @param reason the reason value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withReason(Reason reason) { - this.reason = reason; - return this; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } - - /** - * Set the message value. - * - * @param message the message value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withMessage(String message) { - this.message = message; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/CustomDomain.java b/Samples/3c-guards/OtherClient/models/CustomDomain.java index f7e791460..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/CustomDomain.java +++ b/Samples/3c-guards/OtherClient/models/CustomDomain.java @@ -1,69 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The custom domain assigned to this storage account. This can be set via - * Update. - */ -public class CustomDomain { - /** - * Gets or sets the custom domain name. Name is the CNAME source. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * Indicates whether indirect CName validation is enabled. Default value is - * false. This should only be set on updates. - */ - @JsonProperty(value = "useSubDomain") - private Boolean useSubDomain; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the CustomDomain object itself. - */ - public CustomDomain withName(String name) { - this.name = name; - return this; - } - - /** - * Get the useSubDomain value. - * - * @return the useSubDomain value - */ - public Boolean useSubDomain() { - return this.useSubDomain; - } - - /** - * Set the useSubDomain value. - * - * @param useSubDomain the useSubDomain value to set - * @return the CustomDomain object itself. - */ - public CustomDomain withUseSubDomain(Boolean useSubDomain) { - this.useSubDomain = useSubDomain; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/Endpoints.java b/Samples/3c-guards/OtherClient/models/Endpoints.java index 4359afdea..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/Endpoints.java +++ b/Samples/3c-guards/OtherClient/models/Endpoints.java @@ -1,120 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The URIs that are used to perform a retrieval of a public blob, queue or - * table object. - */ -public class Endpoints { - /** - * Gets the blob endpoint. - */ - @JsonProperty(value = "blob") - private String blob; - - /** - * Gets the queue endpoint. - */ - @JsonProperty(value = "queue") - private String queue; - - /** - * Gets the table endpoint. - */ - @JsonProperty(value = "table") - private String table; - - /** - * Gets the file endpoint. - */ - @JsonProperty(value = "file") - private String file; - - /** - * Get the blob value. - * - * @return the blob value - */ - public String blob() { - return this.blob; - } - - /** - * Set the blob value. - * - * @param blob the blob value to set - * @return the Endpoints object itself. - */ - public Endpoints withBlob(String blob) { - this.blob = blob; - return this; - } - - /** - * Get the queue value. - * - * @return the queue value - */ - public String queue() { - return this.queue; - } - - /** - * Set the queue value. - * - * @param queue the queue value to set - * @return the Endpoints object itself. - */ - public Endpoints withQueue(String queue) { - this.queue = queue; - return this; - } - - /** - * Get the table value. - * - * @return the table value - */ - public String table() { - return this.table; - } - - /** - * Set the table value. - * - * @param table the table value to set - * @return the Endpoints object itself. - */ - public Endpoints withTable(String table) { - this.table = table; - return this; - } - - /** - * Get the file value. - * - * @return the file value - */ - public String file() { - return this.file; - } - - /** - * Set the file value. - * - * @param file the file value to set - * @return the Endpoints object itself. - */ - public Endpoints withFile(String file) { - this.file = file; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/ProvisioningState.java b/Samples/3c-guards/OtherClient/models/ProvisioningState.java index 215602add..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/ProvisioningState.java +++ b/Samples/3c-guards/OtherClient/models/ProvisioningState.java @@ -1,54 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ProvisioningState. - */ -public enum ProvisioningState { - /** Enum value Creating. */ - CREATING("Creating"), - - /** Enum value ResolvingDNS. */ - RESOLVING_DNS("ResolvingDNS"), - - /** Enum value Succeeded. */ - SUCCEEDED("Succeeded"); - - /** The actual serialized value for a ProvisioningState instance. */ - private String value; - - ProvisioningState(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ProvisioningState instance. - * - * @param value the serialized value to parse. - * @return the parsed ProvisioningState object, or null if unable to parse. - */ - @JsonCreator - public static ProvisioningState fromString(String value) { - ProvisioningState[] items = ProvisioningState.values(); - for (ProvisioningState item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/Reason.java b/Samples/3c-guards/OtherClient/models/Reason.java index e1fbd1391..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/Reason.java +++ b/Samples/3c-guards/OtherClient/models/Reason.java @@ -1,51 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for Reason. - */ -public enum Reason { - /** Enum value AccountNameInvalid. */ - ACCOUNT_NAME_INVALID("AccountNameInvalid"), - - /** Enum value AlreadyExists. */ - ALREADY_EXISTS("AlreadyExists"); - - /** The actual serialized value for a Reason instance. */ - private String value; - - Reason(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a Reason instance. - * - * @param value the serialized value to parse. - * @return the parsed Reason object, or null if unable to parse. - */ - @JsonCreator - public static Reason fromString(String value) { - Reason[] items = Reason.values(); - for (Reason item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/Resource.java b/Samples/3c-guards/OtherClient/models/Resource.java index 4a819e1d5..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/Resource.java +++ b/Samples/3c-guards/OtherClient/models/Resource.java @@ -1,113 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Resource model. - */ -public class Resource { - /** - * Resource Id. - */ - @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) - private String id; - - /** - * Resource name. - */ - @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) - private String name; - - /** - * Resource type. - */ - @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) - private String type; - - /** - * Resource location. - */ - @JsonProperty(value = "location") - private String location; - - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Get the location value. - * - * @return the location value - */ - public String location() { - return this.location; - } - - /** - * Set the location value. - * - * @param location the location value to set - * @return the Resource object itself. - */ - public Resource withLocation(String location) { - this.location = location; - return this; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the Resource object itself. - */ - public Resource withTags(Map tags) { - this.tags = tags; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/StorageAccount.java b/Samples/3c-guards/OtherClient/models/StorageAccount.java index 92bd44525..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/StorageAccount.java +++ b/Samples/3c-guards/OtherClient/models/StorageAccount.java @@ -1,322 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import org.joda.time.DateTime; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The storage account. - */ -@JsonFlatten -public class StorageAccount extends Resource { - /** - * Gets the status of the storage account at the time the operation was - * called. Possible values include: 'Creating', 'ResolvingDNS', - * 'Succeeded'. - */ - @JsonProperty(value = "properties.provisioningState") - private ProvisioningState provisioningState; - - /** - * Gets the type of the storage account. Possible values include: - * 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - * 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType") - private AccountType accountType; - - /** - * Gets the URLs that are used to perform a retrieval of a public blob, - * queue or table object.Note that StandardZRS and PremiumLRS accounts only - * return the blob endpoint. - */ - @JsonProperty(value = "properties.primaryEndpoints") - private Endpoints primaryEndpoints; - - /** - * Gets the location of the primary for the storage account. - */ - @JsonProperty(value = "properties.primaryLocation") - private String primaryLocation; - - /** - * Gets the status indicating whether the primary location of the storage - * account is available or unavailable. Possible values include: - * 'Available', 'Unavailable'. - */ - @JsonProperty(value = "properties.statusOfPrimary") - private AccountStatus statusOfPrimary; - - /** - * Gets the timestamp of the most recent instance of a failover to the - * secondary location. Only the most recent timestamp is retained. This - * element is not returned if there has never been a failover instance. - * Only available if the accountType is StandardGRS or StandardRAGRS. - */ - @JsonProperty(value = "properties.lastGeoFailoverTime") - private DateTime lastGeoFailoverTime; - - /** - * Gets the location of the geo replicated secondary for the storage - * account. Only available if the accountType is StandardGRS or - * StandardRAGRS. - */ - @JsonProperty(value = "properties.secondaryLocation") - private String secondaryLocation; - - /** - * Gets the status indicating whether the secondary location of the storage - * account is available or unavailable. Only available if the accountType - * is StandardGRS or StandardRAGRS. Possible values include: 'Available', - * 'Unavailable'. - */ - @JsonProperty(value = "properties.statusOfSecondary") - private AccountStatus statusOfSecondary; - - /** - * Gets the creation date and time of the storage account in UTC. - */ - @JsonProperty(value = "properties.creationTime") - private DateTime creationTime; - - /** - * Gets the user assigned custom domain assigned to this storage account. - */ - @JsonProperty(value = "properties.customDomain") - private CustomDomain customDomain; - - /** - * Gets the URLs that are used to perform a retrieval of a public blob, - * queue or table object from the secondary location of the storage - * account. Only available if the accountType is StandardRAGRS. - */ - @JsonProperty(value = "properties.secondaryEndpoints") - private Endpoints secondaryEndpoints; - - /** - * Get the provisioningState value. - * - * @return the provisioningState value - */ - public ProvisioningState provisioningState() { - return this.provisioningState; - } - - /** - * Set the provisioningState value. - * - * @param provisioningState the provisioningState value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withProvisioningState(ProvisioningState provisioningState) { - this.provisioningState = provisioningState; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - - /** - * Get the primaryEndpoints value. - * - * @return the primaryEndpoints value - */ - public Endpoints primaryEndpoints() { - return this.primaryEndpoints; - } - - /** - * Set the primaryEndpoints value. - * - * @param primaryEndpoints the primaryEndpoints value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withPrimaryEndpoints(Endpoints primaryEndpoints) { - this.primaryEndpoints = primaryEndpoints; - return this; - } - - /** - * Get the primaryLocation value. - * - * @return the primaryLocation value - */ - public String primaryLocation() { - return this.primaryLocation; - } - - /** - * Set the primaryLocation value. - * - * @param primaryLocation the primaryLocation value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withPrimaryLocation(String primaryLocation) { - this.primaryLocation = primaryLocation; - return this; - } - - /** - * Get the statusOfPrimary value. - * - * @return the statusOfPrimary value - */ - public AccountStatus statusOfPrimary() { - return this.statusOfPrimary; - } - - /** - * Set the statusOfPrimary value. - * - * @param statusOfPrimary the statusOfPrimary value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withStatusOfPrimary(AccountStatus statusOfPrimary) { - this.statusOfPrimary = statusOfPrimary; - return this; - } - - /** - * Get the lastGeoFailoverTime value. - * - * @return the lastGeoFailoverTime value - */ - public DateTime lastGeoFailoverTime() { - return this.lastGeoFailoverTime; - } - - /** - * Set the lastGeoFailoverTime value. - * - * @param lastGeoFailoverTime the lastGeoFailoverTime value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withLastGeoFailoverTime(DateTime lastGeoFailoverTime) { - this.lastGeoFailoverTime = lastGeoFailoverTime; - return this; - } - - /** - * Get the secondaryLocation value. - * - * @return the secondaryLocation value - */ - public String secondaryLocation() { - return this.secondaryLocation; - } - - /** - * Set the secondaryLocation value. - * - * @param secondaryLocation the secondaryLocation value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withSecondaryLocation(String secondaryLocation) { - this.secondaryLocation = secondaryLocation; - return this; - } - - /** - * Get the statusOfSecondary value. - * - * @return the statusOfSecondary value - */ - public AccountStatus statusOfSecondary() { - return this.statusOfSecondary; - } - - /** - * Set the statusOfSecondary value. - * - * @param statusOfSecondary the statusOfSecondary value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withStatusOfSecondary(AccountStatus statusOfSecondary) { - this.statusOfSecondary = statusOfSecondary; - return this; - } - - /** - * Get the creationTime value. - * - * @return the creationTime value - */ - public DateTime creationTime() { - return this.creationTime; - } - - /** - * Set the creationTime value. - * - * @param creationTime the creationTime value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withCreationTime(DateTime creationTime) { - this.creationTime = creationTime; - return this; - } - - /** - * Get the customDomain value. - * - * @return the customDomain value - */ - public CustomDomain customDomain() { - return this.customDomain; - } - - /** - * Set the customDomain value. - * - * @param customDomain the customDomain value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withCustomDomain(CustomDomain customDomain) { - this.customDomain = customDomain; - return this; - } - - /** - * Get the secondaryEndpoints value. - * - * @return the secondaryEndpoints value - */ - public Endpoints secondaryEndpoints() { - return this.secondaryEndpoints; - } - - /** - * Set the secondaryEndpoints value. - * - * @param secondaryEndpoints the secondaryEndpoints value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withSecondaryEndpoints(Endpoints secondaryEndpoints) { - this.secondaryEndpoints = secondaryEndpoints; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/StorageAccountCheckNameAvailabilityParameters.java b/Samples/3c-guards/OtherClient/models/StorageAccountCheckNameAvailabilityParameters.java index b34de88bf..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/StorageAccountCheckNameAvailabilityParameters.java +++ b/Samples/3c-guards/OtherClient/models/StorageAccountCheckNameAvailabilityParameters.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The StorageAccountCheckNameAvailabilityParameters model. - */ -public class StorageAccountCheckNameAvailabilityParameters { - /** - * The name property. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * The type property. - */ - @JsonProperty(value = "type") - private String type; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the StorageAccountCheckNameAvailabilityParameters object itself. - */ - public StorageAccountCheckNameAvailabilityParameters withName(String name) { - this.name = name; - return this; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the StorageAccountCheckNameAvailabilityParameters object itself. - */ - public StorageAccountCheckNameAvailabilityParameters withType(String type) { - this.type = type; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/StorageAccountCreateParameters.java b/Samples/3c-guards/OtherClient/models/StorageAccountCreateParameters.java index 58aa37ec1..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/StorageAccountCreateParameters.java +++ b/Samples/3c-guards/OtherClient/models/StorageAccountCreateParameters.java @@ -1,97 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The parameters to provide for the account. - */ -@JsonFlatten -public class StorageAccountCreateParameters { - /** - * Resource location. - */ - @JsonProperty(value = "location", required = true) - private String location; - - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Gets or sets the account type. Possible values include: 'Standard_LRS', - * 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType", required = true) - private AccountType accountType; - - /** - * Get the location value. - * - * @return the location value - */ - public String location() { - return this.location; - } - - /** - * Set the location value. - * - * @param location the location value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withLocation(String location) { - this.location = location; - return this; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/StorageAccountKeys.java b/Samples/3c-guards/OtherClient/models/StorageAccountKeys.java index 03b769713..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/StorageAccountKeys.java +++ b/Samples/3c-guards/OtherClient/models/StorageAccountKeys.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The access keys for the storage account. - */ -public class StorageAccountKeys { - /** - * Gets the value of key 1. - */ - @JsonProperty(value = "key1") - private String key1; - - /** - * Gets the value of key 2. - */ - @JsonProperty(value = "key2") - private String key2; - - /** - * Get the key1 value. - * - * @return the key1 value - */ - public String key1() { - return this.key1; - } - - /** - * Set the key1 value. - * - * @param key1 the key1 value to set - * @return the StorageAccountKeys object itself. - */ - public StorageAccountKeys withKey1(String key1) { - this.key1 = key1; - return this; - } - - /** - * Get the key2 value. - * - * @return the key2 value - */ - public String key2() { - return this.key2; - } - - /** - * Set the key2 value. - * - * @param key2 the key2 value to set - * @return the StorageAccountKeys object itself. - */ - public StorageAccountKeys withKey2(String key2) { - this.key2 = key2; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/StorageAccountListResult.java b/Samples/3c-guards/OtherClient/models/StorageAccountListResult.java index 214b14455..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/StorageAccountListResult.java +++ b/Samples/3c-guards/OtherClient/models/StorageAccountListResult.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The list storage accounts operation response. - */ -public class StorageAccountListResult { - /** - * Gets the list of storage accounts and their properties. - */ - @JsonProperty(value = "value") - private List value; - - /** - * Get the value value. - * - * @return the value value - */ - public List value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the StorageAccountListResult object itself. - */ - public StorageAccountListResult withValue(List value) { - this.value = value; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/StorageAccountRegenerateKeyParameters.java b/Samples/3c-guards/OtherClient/models/StorageAccountRegenerateKeyParameters.java index 90892708f..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/StorageAccountRegenerateKeyParameters.java +++ b/Samples/3c-guards/OtherClient/models/StorageAccountRegenerateKeyParameters.java @@ -1,41 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The StorageAccountRegenerateKeyParameters model. - */ -public class StorageAccountRegenerateKeyParameters { - /** - * The keyName property. - */ - @JsonProperty(value = "keyName", required = true) - private String keyName; - - /** - * Get the keyName value. - * - * @return the keyName value - */ - public String keyName() { - return this.keyName; - } - - /** - * Set the keyName value. - * - * @param keyName the keyName value to set - * @return the StorageAccountRegenerateKeyParameters object itself. - */ - public StorageAccountRegenerateKeyParameters withKeyName(String keyName) { - this.keyName = keyName; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/StorageAccountUpdateParameters.java b/Samples/3c-guards/OtherClient/models/StorageAccountUpdateParameters.java index d1958668c..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/StorageAccountUpdateParameters.java +++ b/Samples/3c-guards/OtherClient/models/StorageAccountUpdateParameters.java @@ -1,103 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The parameters to update on the account. - */ -@JsonFlatten -public class StorageAccountUpdateParameters { - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Gets or sets the account type. Note that StandardZRS and PremiumLRS - * accounts cannot be changed to other account types, and other account - * types cannot be changed to StandardZRS or PremiumLRS. Possible values - * include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType") - private AccountType accountType; - - /** - * User domain assigned to the storage account. Name is the CNAME source. - * Only one custom domain is supported per storage account at this time. To - * clear the existing custom domain, use an empty string for the custom - * domain name property. - */ - @JsonProperty(value = "properties.customDomain") - private CustomDomain customDomain; - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - - /** - * Get the customDomain value. - * - * @return the customDomain value - */ - public CustomDomain customDomain() { - return this.customDomain; - } - - /** - * Set the customDomain value. - * - * @param customDomain the customDomain value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withCustomDomain(CustomDomain customDomain) { - this.customDomain = customDomain; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/Usage.java b/Samples/3c-guards/OtherClient/models/Usage.java index 45b3bf140..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/Usage.java +++ b/Samples/3c-guards/OtherClient/models/Usage.java @@ -1,121 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Describes Storage Resource Usage. - */ -public class Usage { - /** - * Gets the unit of measurement. Possible values include: 'Count', 'Bytes', - * 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond'. - */ - @JsonProperty(value = "unit", required = true) - private UsageUnit unit; - - /** - * Gets the current count of the allocated resources in the subscription. - */ - @JsonProperty(value = "currentValue", required = true) - private int currentValue; - - /** - * Gets the maximum count of the resources that can be allocated in the - * subscription. - */ - @JsonProperty(value = "limit", required = true) - private int limit; - - /** - * Gets the name of the type of usage. - */ - @JsonProperty(value = "name", required = true) - private UsageName name; - - /** - * Get the unit value. - * - * @return the unit value - */ - public UsageUnit unit() { - return this.unit; - } - - /** - * Set the unit value. - * - * @param unit the unit value to set - * @return the Usage object itself. - */ - public Usage withUnit(UsageUnit unit) { - this.unit = unit; - return this; - } - - /** - * Get the currentValue value. - * - * @return the currentValue value - */ - public int currentValue() { - return this.currentValue; - } - - /** - * Set the currentValue value. - * - * @param currentValue the currentValue value to set - * @return the Usage object itself. - */ - public Usage withCurrentValue(int currentValue) { - this.currentValue = currentValue; - return this; - } - - /** - * Get the limit value. - * - * @return the limit value - */ - public int limit() { - return this.limit; - } - - /** - * Set the limit value. - * - * @param limit the limit value to set - * @return the Usage object itself. - */ - public Usage withLimit(int limit) { - this.limit = limit; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public UsageName name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Usage object itself. - */ - public Usage withName(UsageName name) { - this.name = name; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/UsageListResult.java b/Samples/3c-guards/OtherClient/models/UsageListResult.java index a70f53311..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/UsageListResult.java +++ b/Samples/3c-guards/OtherClient/models/UsageListResult.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The List Usages operation response. - */ -public class UsageListResult { - /** - * Gets or sets the list Storage Resource Usages. - */ - @JsonProperty(value = "value") - private List value; - - /** - * Get the value value. - * - * @return the value value - */ - public List value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the UsageListResult object itself. - */ - public UsageListResult withValue(List value) { - this.value = value; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/UsageName.java b/Samples/3c-guards/OtherClient/models/UsageName.java index a0f2dffd5..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/UsageName.java +++ b/Samples/3c-guards/OtherClient/models/UsageName.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Usage Names. - */ -public class UsageName { - /** - * Gets a string describing the resource name. - */ - @JsonProperty(value = "value") - private String value; - - /** - * Gets a localized string describing the resource name. - */ - @JsonProperty(value = "localizedValue") - private String localizedValue; - - /** - * Get the value value. - * - * @return the value value - */ - public String value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the UsageName object itself. - */ - public UsageName withValue(String value) { - this.value = value; - return this; - } - - /** - * Get the localizedValue value. - * - * @return the localizedValue value - */ - public String localizedValue() { - return this.localizedValue; - } - - /** - * Set the localizedValue value. - * - * @param localizedValue the localizedValue value to set - * @return the UsageName object itself. - */ - public UsageName withLocalizedValue(String localizedValue) { - this.localizedValue = localizedValue; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/UsageUnit.java b/Samples/3c-guards/OtherClient/models/UsageUnit.java index 3c205be70..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/UsageUnit.java +++ b/Samples/3c-guards/OtherClient/models/UsageUnit.java @@ -1,63 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for UsageUnit. - */ -public enum UsageUnit { - /** Enum value Count. */ - COUNT("Count"), - - /** Enum value Bytes. */ - BYTES("Bytes"), - - /** Enum value Seconds. */ - SECONDS("Seconds"), - - /** Enum value Percent. */ - PERCENT("Percent"), - - /** Enum value CountsPerSecond. */ - COUNTS_PER_SECOND("CountsPerSecond"), - - /** Enum value BytesPerSecond. */ - BYTES_PER_SECOND("BytesPerSecond"); - - /** The actual serialized value for a UsageUnit instance. */ - private String value; - - UsageUnit(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a UsageUnit instance. - * - * @param value the serialized value to parse. - * @return the parsed UsageUnit object, or null if unable to parse. - */ - @JsonCreator - public static UsageUnit fromString(String value) { - UsageUnit[] items = UsageUnit.values(); - for (UsageUnit item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/models/package-info.java b/Samples/3c-guards/OtherClient/models/package-info.java index 17e1cbb51..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/models/package-info.java +++ b/Samples/3c-guards/OtherClient/models/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the models classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage.models; +SRC \ No newline at end of file diff --git a/Samples/3c-guards/OtherClient/package-info.java b/Samples/3c-guards/OtherClient/package-info.java index 325714cc1..9d6cafc2c 100644 --- a/Samples/3c-guards/OtherClient/package-info.java +++ b/Samples/3c-guards/OtherClient/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage; +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/IStorageAccounts.cs b/Samples/3d-custom-validation/Client/IStorageAccounts.cs index e821ba839..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/IStorageAccounts.cs +++ b/Samples/3d-custom-validation/Client/IStorageAccounts.cs @@ -1,278 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial interface IStorageAccounts - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one - /// property can be changed at a time using this API. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 - /// for the default keys - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/IStorageManagementClient.cs b/Samples/3d-custom-validation/Client/IStorageManagementClient.cs index 361f9fcad..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/IStorageManagementClient.cs +++ b/Samples/3d-custom-validation/Client/IStorageManagementClient.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Models; - using Newtonsoft.Json; - - /// - /// The Storage Management Client. - /// - public partial interface IStorageManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - string ApiVersion { get; set; } - - - /// - /// Gets the IStorageAccounts. - /// - IStorageAccounts StorageAccounts { get; } - - /// - /// Gets the IUsageOperations. - /// - IUsageOperations Usage { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/IUsageOperations.cs b/Samples/3d-custom-validation/Client/IUsageOperations.cs index 1e96fecd4..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/IUsageOperations.cs +++ b/Samples/3d-custom-validation/Client/IUsageOperations.cs @@ -1,42 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial interface IUsageOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/AccountStatus.cs b/Samples/3d-custom-validation/Client/Models/AccountStatus.cs index add75dbff..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/AccountStatus.cs +++ b/Samples/3d-custom-validation/Client/Models/AccountStatus.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/AccountType.cs b/Samples/3d-custom-validation/Client/Models/AccountType.cs index 927636470..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/AccountType.cs +++ b/Samples/3d-custom-validation/Client/Models/AccountType.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/CheckNameAvailabilityResult.cs b/Samples/3d-custom-validation/Client/Models/CheckNameAvailabilityResult.cs index 3cd5b4328..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/CheckNameAvailabilityResult.cs +++ b/Samples/3d-custom-validation/Client/Models/CheckNameAvailabilityResult.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/CustomDomain.cs b/Samples/3d-custom-validation/Client/Models/CustomDomain.cs index 7e45930f6..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/CustomDomain.cs +++ b/Samples/3d-custom-validation/Client/Models/CustomDomain.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/Endpoints.cs b/Samples/3d-custom-validation/Client/Models/Endpoints.cs index cde486b00..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/Endpoints.cs +++ b/Samples/3d-custom-validation/Client/Models/Endpoints.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/ProvisioningState.cs b/Samples/3d-custom-validation/Client/Models/ProvisioningState.cs index b5b85bac3..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/ProvisioningState.cs +++ b/Samples/3d-custom-validation/Client/Models/ProvisioningState.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/Reason.cs b/Samples/3d-custom-validation/Client/Models/Reason.cs index ecaf08ffd..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/Reason.cs +++ b/Samples/3d-custom-validation/Client/Models/Reason.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/Resource.cs b/Samples/3d-custom-validation/Client/Models/Resource.cs index 9074a464c..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/Resource.cs +++ b/Samples/3d-custom-validation/Client/Models/Resource.cs @@ -1,78 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/StorageAccount.cs b/Samples/3d-custom-validation/Client/Models/StorageAccount.cs index ab7cb2a5a..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/StorageAccount.cs +++ b/Samples/3d-custom-validation/Client/Models/StorageAccount.cs @@ -1,198 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/3d-custom-validation/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs index 4c0b6121c..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/3d-custom-validation/Client/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/StorageAccountCreateParameters.cs b/Samples/3d-custom-validation/Client/Models/StorageAccountCreateParameters.cs index 4338b6c4a..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/StorageAccountCreateParameters.cs +++ b/Samples/3d-custom-validation/Client/Models/StorageAccountCreateParameters.cs @@ -1,87 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/StorageAccountKeys.cs b/Samples/3d-custom-validation/Client/Models/StorageAccountKeys.cs index 44c01154f..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/StorageAccountKeys.cs +++ b/Samples/3d-custom-validation/Client/Models/StorageAccountKeys.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/StorageAccountListResult.cs b/Samples/3d-custom-validation/Client/Models/StorageAccountListResult.cs index bfcdd6042..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/StorageAccountListResult.cs +++ b/Samples/3d-custom-validation/Client/Models/StorageAccountListResult.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The list storage accounts operation response. - /// - public partial class StorageAccountListResult - { - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - public StorageAccountListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountListResult class. - /// - /// Gets the list of storage accounts and their - /// properties. - public StorageAccountListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of storage accounts and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/3d-custom-validation/Client/Models/StorageAccountRegenerateKeyParameters.cs index 8f04bcd7a..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/3d-custom-validation/Client/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/StorageAccountUpdateParameters.cs b/Samples/3d-custom-validation/Client/Models/StorageAccountUpdateParameters.cs index 5368388b0..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/StorageAccountUpdateParameters.cs +++ b/Samples/3d-custom-validation/Client/Models/StorageAccountUpdateParameters.cs @@ -1,99 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/Usage.cs b/Samples/3d-custom-validation/Client/Models/Usage.cs index cc75396a7..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/Usage.cs +++ b/Samples/3d-custom-validation/Client/Models/Usage.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes Storage Resource Usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/UsageListResult.cs b/Samples/3d-custom-validation/Client/Models/UsageListResult.cs index 1e884f4d1..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/UsageListResult.cs +++ b/Samples/3d-custom-validation/Client/Models/UsageListResult.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List Usages operation response. - /// - public partial class UsageListResult - { - /// - /// Initializes a new instance of the UsageListResult class. - /// - public UsageListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageListResult class. - /// - /// Gets or sets the list Storage Resource - /// Usages. - public UsageListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the list Storage Resource Usages. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/UsageName.cs b/Samples/3d-custom-validation/Client/Models/UsageName.cs index 8fa9f973f..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/UsageName.cs +++ b/Samples/3d-custom-validation/Client/Models/UsageName.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/Models/UsageUnit.cs b/Samples/3d-custom-validation/Client/Models/UsageUnit.cs index cf012fd42..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/Models/UsageUnit.cs +++ b/Samples/3d-custom-validation/Client/Models/UsageUnit.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/StorageAccounts.cs b/Samples/3d-custom-validation/Client/StorageAccounts.cs index a80fb5faa..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/StorageAccounts.cs +++ b/Samples/3d-custom-validation/Client/StorageAccounts.cs @@ -1,1609 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccounts operations. - /// - public partial class StorageAccounts : IServiceOperations, IStorageAccounts - { - /// - /// Initializes a new instance of the StorageAccounts class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageAccounts(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - accountName.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperties", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (regenerateKey == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "regenerateKey"); - } - if (regenerateKey != null) - { - regenerateKey.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/StorageAccountsExtensions.cs b/Samples/3d-custom-validation/Client/StorageAccountsExtensions.cs index bfc1c0dc7..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/StorageAccountsExtensions.cs +++ b/Samples/3d-custom-validation/Client/StorageAccountsExtensions.cs @@ -1,438 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccounts. - /// - public static partial class StorageAccountsExtensions - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName) - { - return operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult(); - } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this IStorageAccounts operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount Create(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static void Delete(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static StorageAccount GetProperties(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.GetPropertiesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertiesAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - public static StorageAccount Update(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - public static StorageAccountKeys ListKeys(this IStorageAccounts operations, string resourceGroupName, string accountName) - { - return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - public static StorageAccountListResult List(this IStorageAccounts operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IStorageAccounts operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - public static StorageAccountListResult ListByResourceGroup(this IStorageAccounts operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task ListByResourceGroupAsync(this IStorageAccounts operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - public static StorageAccountKeys RegenerateKey(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey) - { - return operations.RegenerateKeyAsync(resourceGroupName, accountName, regenerateKey).GetAwaiter().GetResult(); - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this IStorageAccounts operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, regenerateKey, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/StorageManagementClient.cs b/Samples/3d-custom-validation/Client/StorageManagementClient.cs index 711e6ddf9..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/StorageManagementClient.cs +++ b/Samples/3d-custom-validation/Client/StorageManagementClient.cs @@ -1,172 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// The Storage Management Client. - /// - public partial class StorageManagementClient : ServiceClient, IStorageManagementClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - public string ApiVersion { get; set; } - - /// - /// Gets the IStorageAccounts. - /// - public virtual IStorageAccounts StorageAccounts { get; private set; } - - /// - /// Gets the IUsageOperations. - /// - public virtual IUsageOperations Usage { get; private set; } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public StorageManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public StorageManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - StorageAccounts = new StorageAccounts(this); - Usage = new UsageOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/UsageOperations.cs b/Samples/3d-custom-validation/Client/UsageOperations.cs index a07be839c..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/UsageOperations.cs +++ b/Samples/3d-custom-validation/Client/UsageOperations.cs @@ -1,194 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial class UsageOperations : IServiceOperations, IUsageOperations - { - /// - /// Initializes a new instance of the UsageOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public UsageOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3d-custom-validation/Client/UsageOperationsExtensions.cs b/Samples/3d-custom-validation/Client/UsageOperationsExtensions.cs index f87f4f7df..9d6cafc2c 100644 --- a/Samples/3d-custom-validation/Client/UsageOperationsExtensions.cs +++ b/Samples/3d-custom-validation/Client/UsageOperationsExtensions.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsageOperations. - /// - public static partial class UsageOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - public static UsageListResult List(this IUsageOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task ListAsync(this IUsageOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/IStorageAccountsOperations.cs b/Samples/3e-batch-mode/output1/IStorageAccountsOperations.cs index 77dde94c9..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/IStorageAccountsOperations.cs +++ b/Samples/3e-batch-mode/output1/IStorageAccountsOperations.cs @@ -1,313 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccountsOperations operations. - /// - public partial interface IStorageAccountsOperations - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Returns the properties for the specified storage account including - /// but not limited to name, account type, location, and account - /// status. The ListKeys operation should be used to retrieve storage - /// keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the account type or tags for a storage account. It can also - /// be used to add a custom domain (note that custom domains cannot be - /// added via the Create operation). Only one custom domain is - /// supported per storage account. In order to replace a custom domain, - /// the old value must be cleared before a new value may be set. To - /// clear a custom domain, simply update the custom domain with empty - /// string. Then call update again with the new cutsom domain name. The - /// update API can only be used to update one of tags, accountType, or - /// customDomain per call. To update multiple of these properties, call - /// the API multiple times with one change per call. This call does not - /// change the storage keys for the account. If you want to change - /// storage account keys, use the RegenerateKey operation. The location - /// and name of the storage account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one - /// property can be changed at a time using this API. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the subscription. - /// Note that storage keys are not returned; use the ListKeys operation - /// for this. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all the storage accounts available under the given resource - /// group. Note that storage keys are not returned; use the ListKeys - /// operation for this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 - /// for the default keys - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Asynchronously creates a new storage account with the specified - /// parameters. Existing accounts cannot be updated with this API and - /// should instead use the Update Storage Account API. If an account is - /// already created and subsequent PUT request is issued with exact - /// same set of properties, then HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource - /// group. Storage account names must be between 3 and 24 characters in - /// length and use numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/IStorageManagementClient.cs b/Samples/3e-batch-mode/output1/IStorageManagementClient.cs index d8502441d..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/IStorageManagementClient.cs +++ b/Samples/3e-batch-mode/output1/IStorageManagementClient.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - - /// - /// The Storage Management Client. - /// - public partial interface IStorageManagementClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - string ApiVersion { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// Gets the IStorageAccountsOperations. - /// - IStorageAccountsOperations StorageAccounts { get; } - - /// - /// Gets the IUsageOperations. - /// - IUsageOperations Usage { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/IUsageOperations.cs b/Samples/3e-batch-mode/output1/IUsageOperations.cs index 58a08df97..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/IUsageOperations.cs +++ b/Samples/3e-batch-mode/output1/IUsageOperations.cs @@ -1,43 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - public partial interface IUsageOperations - { - /// - /// Gets the current usage count and the limit for the resources under - /// the subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/AccountStatus.cs b/Samples/3e-batch-mode/output1/Models/AccountStatus.cs index add75dbff..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/AccountStatus.cs +++ b/Samples/3e-batch-mode/output1/Models/AccountStatus.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountStatus. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountStatus - { - [EnumMember(Value = "Available")] - Available, - [EnumMember(Value = "Unavailable")] - Unavailable - } - internal static class AccountStatusEnumExtension - { - internal static string ToSerializedValue(this AccountStatus? value) - { - return value == null ? null : ((AccountStatus)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountStatus value) - { - switch( value ) - { - case AccountStatus.Available: - return "Available"; - case AccountStatus.Unavailable: - return "Unavailable"; - } - return null; - } - - internal static AccountStatus? ParseAccountStatus(this string value) - { - switch( value ) - { - case "Available": - return AccountStatus.Available; - case "Unavailable": - return AccountStatus.Unavailable; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/AccountType.cs b/Samples/3e-batch-mode/output1/Models/AccountType.cs index 927636470..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/AccountType.cs +++ b/Samples/3e-batch-mode/output1/Models/AccountType.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for AccountType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum AccountType - { - [EnumMember(Value = "Standard_LRS")] - StandardLRS, - [EnumMember(Value = "Standard_ZRS")] - StandardZRS, - [EnumMember(Value = "Standard_GRS")] - StandardGRS, - [EnumMember(Value = "Standard_RAGRS")] - StandardRAGRS, - [EnumMember(Value = "Premium_LRS")] - PremiumLRS - } - internal static class AccountTypeEnumExtension - { - internal static string ToSerializedValue(this AccountType? value) - { - return value == null ? null : ((AccountType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this AccountType value) - { - switch( value ) - { - case AccountType.StandardLRS: - return "Standard_LRS"; - case AccountType.StandardZRS: - return "Standard_ZRS"; - case AccountType.StandardGRS: - return "Standard_GRS"; - case AccountType.StandardRAGRS: - return "Standard_RAGRS"; - case AccountType.PremiumLRS: - return "Premium_LRS"; - } - return null; - } - - internal static AccountType? ParseAccountType(this string value) - { - switch( value ) - { - case "Standard_LRS": - return AccountType.StandardLRS; - case "Standard_ZRS": - return AccountType.StandardZRS; - case "Standard_GRS": - return AccountType.StandardGRS; - case "Standard_RAGRS": - return AccountType.StandardRAGRS; - case "Premium_LRS": - return AccountType.PremiumLRS; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/CheckNameAvailabilityResult.cs b/Samples/3e-batch-mode/output1/Models/CheckNameAvailabilityResult.cs index 3cd5b4328..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/CheckNameAvailabilityResult.cs +++ b/Samples/3e-batch-mode/output1/Models/CheckNameAvailabilityResult.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The CheckNameAvailability operation response. - /// - public partial class CheckNameAvailabilityResult - { - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - public CheckNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CheckNameAvailabilityResult - /// class. - /// - /// Gets a boolean value that indicates - /// whether the name is available for you to use. If true, the name is - /// available. If false, the name has already been taken or invalid and - /// cannot be used. - /// Gets the reason that a storage account name - /// could not be used. The Reason element is only returned if - /// NameAvailable is false. Possible values include: - /// 'AccountNameInvalid', 'AlreadyExists' - /// Gets an error message explaining the Reason - /// value in more detail. - public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a boolean value that indicates whether the name is available - /// for you to use. If true, the name is available. If false, the name - /// has already been taken or invalid and cannot be used. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets the reason that a storage account name could not be used. The - /// Reason element is only returned if NameAvailable is false. Possible - /// values include: 'AccountNameInvalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public Reason? Reason { get; set; } - - /// - /// Gets an error message explaining the Reason value in more detail. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/CustomDomain.cs b/Samples/3e-batch-mode/output1/Models/CustomDomain.cs index 7e45930f6..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/CustomDomain.cs +++ b/Samples/3e-batch-mode/output1/Models/CustomDomain.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The custom domain assigned to this storage account. This can be set via - /// Update. - /// - public partial class CustomDomain - { - /// - /// Initializes a new instance of the CustomDomain class. - /// - public CustomDomain() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CustomDomain class. - /// - /// Gets or sets the custom domain name. Name is the - /// CNAME source. - /// Indicates whether indirect CName - /// validation is enabled. Default value is false. This should only be - /// set on updates - public CustomDomain(string name, bool? useSubDomain = default(bool?)) - { - Name = name; - UseSubDomain = useSubDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the custom domain name. Name is the CNAME source. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets indicates whether indirect CName validation is - /// enabled. Default value is false. This should only be set on updates - /// - [JsonProperty(PropertyName = "useSubDomain")] - public bool? UseSubDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/Endpoints.cs b/Samples/3e-batch-mode/output1/Models/Endpoints.cs index cde486b00..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/Endpoints.cs +++ b/Samples/3e-batch-mode/output1/Models/Endpoints.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The URIs that are used to perform a retrieval of a public blob, queue - /// or table object. - /// - public partial class Endpoints - { - /// - /// Initializes a new instance of the Endpoints class. - /// - public Endpoints() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Endpoints class. - /// - /// Gets the blob endpoint. - /// Gets the queue endpoint. - /// Gets the table endpoint. - /// Gets the file endpoint. - public Endpoints(string blob = default(string), string queue = default(string), string table = default(string), string file = default(string)) - { - Blob = blob; - Queue = queue; - Table = table; - File = file; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the blob endpoint. - /// - [JsonProperty(PropertyName = "blob")] - public string Blob { get; set; } - - /// - /// Gets the queue endpoint. - /// - [JsonProperty(PropertyName = "queue")] - public string Queue { get; set; } - - /// - /// Gets the table endpoint. - /// - [JsonProperty(PropertyName = "table")] - public string Table { get; set; } - - /// - /// Gets the file endpoint. - /// - [JsonProperty(PropertyName = "file")] - public string File { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/Page.cs b/Samples/3e-batch-mode/output1/Models/Page.cs index f0225b4df..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/Page.cs +++ b/Samples/3e-batch-mode/output1/Models/Page.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - - /// - /// Defines a page in Azure responses. - /// - /// Type of the page content items - [JsonObject] - public class Page : IPage - { - /// - /// Gets the link to the next page. - /// - [JsonProperty("")] - public string NextPageLink { get; private set; } - - [JsonProperty("value")] - private IList Items{ get; set; } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/ProvisioningState.cs b/Samples/3e-batch-mode/output1/Models/ProvisioningState.cs index b5b85bac3..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/ProvisioningState.cs +++ b/Samples/3e-batch-mode/output1/Models/ProvisioningState.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ProvisioningState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ProvisioningState - { - [EnumMember(Value = "Creating")] - Creating, - [EnumMember(Value = "ResolvingDNS")] - ResolvingDNS, - [EnumMember(Value = "Succeeded")] - Succeeded - } - internal static class ProvisioningStateEnumExtension - { - internal static string ToSerializedValue(this ProvisioningState? value) - { - return value == null ? null : ((ProvisioningState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ProvisioningState value) - { - switch( value ) - { - case ProvisioningState.Creating: - return "Creating"; - case ProvisioningState.ResolvingDNS: - return "ResolvingDNS"; - case ProvisioningState.Succeeded: - return "Succeeded"; - } - return null; - } - - internal static ProvisioningState? ParseProvisioningState(this string value) - { - switch( value ) - { - case "Creating": - return ProvisioningState.Creating; - case "ResolvingDNS": - return ProvisioningState.ResolvingDNS; - case "Succeeded": - return ProvisioningState.Succeeded; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/Reason.cs b/Samples/3e-batch-mode/output1/Models/Reason.cs index ecaf08ffd..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/Reason.cs +++ b/Samples/3e-batch-mode/output1/Models/Reason.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for Reason. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum Reason - { - [EnumMember(Value = "AccountNameInvalid")] - AccountNameInvalid, - [EnumMember(Value = "AlreadyExists")] - AlreadyExists - } - internal static class ReasonEnumExtension - { - internal static string ToSerializedValue(this Reason? value) - { - return value == null ? null : ((Reason)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this Reason value) - { - switch( value ) - { - case Reason.AccountNameInvalid: - return "AccountNameInvalid"; - case Reason.AlreadyExists: - return "AlreadyExists"; - } - return null; - } - - internal static Reason? ParseReason(this string value) - { - switch( value ) - { - case "AccountNameInvalid": - return Reason.AccountNameInvalid; - case "AlreadyExists": - return Reason.AlreadyExists; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/Resource.cs b/Samples/3e-batch-mode/output1/Models/Resource.cs index eef720b30..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/Resource.cs +++ b/Samples/3e-batch-mode/output1/Models/Resource.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource : IResource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets resource Id - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets resource name - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/StorageAccount.cs b/Samples/3e-batch-mode/output1/Models/StorageAccount.cs index ab7cb2a5a..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/StorageAccount.cs +++ b/Samples/3e-batch-mode/output1/Models/StorageAccount.cs @@ -1,198 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The storage account. - /// - [JsonTransformation] - public partial class StorageAccount : Resource - { - /// - /// Initializes a new instance of the StorageAccount class. - /// - public StorageAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccount class. - /// - /// Resource Id - /// Resource name - /// Resource type - /// Resource location - /// Resource tags - /// Gets the status of the storage - /// account at the time the operation was called. Possible values - /// include: 'Creating', 'ResolvingDNS', 'Succeeded' - /// Gets the type of the storage account. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object.Note - /// that StandardZRS and PremiumLRS accounts only return the blob - /// endpoint. - /// Gets the location of the primary for - /// the storage account. - /// Gets the status indicating whether - /// the primary location of the storage account is available or - /// unavailable. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the timestamp of the most - /// recent instance of a failover to the secondary location. Only the - /// most recent timestamp is retained. This element is not returned if - /// there has never been a failover instance. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the location of the geo - /// replicated secondary for the storage account. Only available if the - /// accountType is StandardGRS or StandardRAGRS. - /// Gets the status indicating whether - /// the secondary location of the storage account is available or - /// unavailable. Only available if the accountType is StandardGRS or - /// StandardRAGRS. Possible values include: 'Available', - /// 'Unavailable' - /// Gets the creation date and time of the - /// storage account in UTC. - /// Gets the user assigned custom domain - /// assigned to this storage account. - /// Gets the URLs that are used to - /// perform a retrieval of a public blob, queue or table object from - /// the secondary location of the storage account. Only available if - /// the accountType is StandardRAGRS. - public StorageAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ProvisioningState? provisioningState = default(ProvisioningState?), AccountType? accountType = default(AccountType?), Endpoints primaryEndpoints = default(Endpoints), string primaryLocation = default(string), AccountStatus? statusOfPrimary = default(AccountStatus?), System.DateTime? lastGeoFailoverTime = default(System.DateTime?), string secondaryLocation = default(string), AccountStatus? statusOfSecondary = default(AccountStatus?), System.DateTime? creationTime = default(System.DateTime?), CustomDomain customDomain = default(CustomDomain), Endpoints secondaryEndpoints = default(Endpoints)) - : base(id, name, type, location, tags) - { - ProvisioningState = provisioningState; - AccountType = accountType; - PrimaryEndpoints = primaryEndpoints; - PrimaryLocation = primaryLocation; - StatusOfPrimary = statusOfPrimary; - LastGeoFailoverTime = lastGeoFailoverTime; - SecondaryLocation = secondaryLocation; - StatusOfSecondary = statusOfSecondary; - CreationTime = creationTime; - CustomDomain = customDomain; - SecondaryEndpoints = secondaryEndpoints; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the status of the storage account at the time the operation - /// was called. Possible values include: 'Creating', 'ResolvingDNS', - /// 'Succeeded' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public ProvisioningState? ProvisioningState { get; set; } - - /// - /// Gets the type of the storage account. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object.Note that StandardZRS and PremiumLRS - /// accounts only return the blob endpoint. - /// - [JsonProperty(PropertyName = "properties.primaryEndpoints")] - public Endpoints PrimaryEndpoints { get; set; } - - /// - /// Gets the location of the primary for the storage account. - /// - [JsonProperty(PropertyName = "properties.primaryLocation")] - public string PrimaryLocation { get; set; } - - /// - /// Gets the status indicating whether the primary location of the - /// storage account is available or unavailable. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfPrimary")] - public AccountStatus? StatusOfPrimary { get; set; } - - /// - /// Gets the timestamp of the most recent instance of a failover to the - /// secondary location. Only the most recent timestamp is retained. - /// This element is not returned if there has never been a failover - /// instance. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.lastGeoFailoverTime")] - public System.DateTime? LastGeoFailoverTime { get; set; } - - /// - /// Gets the location of the geo replicated secondary for the storage - /// account. Only available if the accountType is StandardGRS or - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryLocation")] - public string SecondaryLocation { get; set; } - - /// - /// Gets the status indicating whether the secondary location of the - /// storage account is available or unavailable. Only available if the - /// accountType is StandardGRS or StandardRAGRS. Possible values - /// include: 'Available', 'Unavailable' - /// - [JsonProperty(PropertyName = "properties.statusOfSecondary")] - public AccountStatus? StatusOfSecondary { get; set; } - - /// - /// Gets the creation date and time of the storage account in UTC. - /// - [JsonProperty(PropertyName = "properties.creationTime")] - public System.DateTime? CreationTime { get; set; } - - /// - /// Gets the user assigned custom domain assigned to this storage - /// account. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Gets the URLs that are used to perform a retrieval of a public - /// blob, queue or table object from the secondary location of the - /// storage account. Only available if the accountType is - /// StandardRAGRS. - /// - [JsonProperty(PropertyName = "properties.secondaryEndpoints")] - public Endpoints SecondaryEndpoints { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/StorageAccountCheckNameAvailabilityParameters.cs b/Samples/3e-batch-mode/output1/Models/StorageAccountCheckNameAvailabilityParameters.cs index 4c0b6121c..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/StorageAccountCheckNameAvailabilityParameters.cs +++ b/Samples/3e-batch-mode/output1/Models/StorageAccountCheckNameAvailabilityParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountCheckNameAvailabilityParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountCheckNameAvailabilityParameters class. - /// - public StorageAccountCheckNameAvailabilityParameters(string name, string type = default(string)) - { - Name = name; - Type = type; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/StorageAccountCreateParameters.cs b/Samples/3e-batch-mode/output1/Models/StorageAccountCreateParameters.cs index 261f57172..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/StorageAccountCreateParameters.cs +++ b/Samples/3e-batch-mode/output1/Models/StorageAccountCreateParameters.cs @@ -1,88 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to provide for the account. - /// - [JsonTransformation] - public partial class StorageAccountCreateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - public StorageAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountCreateParameters - /// class. - /// - /// Resource location - /// Gets or sets the account type. Possible - /// values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - /// 'Standard_RAGRS', 'Premium_LRS' - /// Resource tags - public StorageAccountCreateParameters(string location, AccountType accountType, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - AccountType = accountType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource location - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Possible values include: - /// 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType AccountType { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/StorageAccountKeys.cs b/Samples/3e-batch-mode/output1/Models/StorageAccountKeys.cs index 44c01154f..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/StorageAccountKeys.cs +++ b/Samples/3e-batch-mode/output1/Models/StorageAccountKeys.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The access keys for the storage account. - /// - public partial class StorageAccountKeys - { - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - public StorageAccountKeys() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountKeys class. - /// - /// Gets the value of key 1. - /// Gets the value of key 2. - public StorageAccountKeys(string key1 = default(string), string key2 = default(string)) - { - Key1 = key1; - Key2 = key2; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the value of key 1. - /// - [JsonProperty(PropertyName = "key1")] - public string Key1 { get; set; } - - /// - /// Gets the value of key 2. - /// - [JsonProperty(PropertyName = "key2")] - public string Key2 { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/StorageAccountRegenerateKeyParameters.cs b/Samples/3e-batch-mode/output1/Models/StorageAccountRegenerateKeyParameters.cs index 8f04bcd7a..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/StorageAccountRegenerateKeyParameters.cs +++ b/Samples/3e-batch-mode/output1/Models/StorageAccountRegenerateKeyParameters.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class StorageAccountRegenerateKeyParameters - { - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// StorageAccountRegenerateKeyParameters class. - /// - public StorageAccountRegenerateKeyParameters(string keyName) - { - KeyName = keyName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "keyName")] - public string KeyName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/StorageAccountUpdateParameters.cs b/Samples/3e-batch-mode/output1/Models/StorageAccountUpdateParameters.cs index 937b4acc9..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/StorageAccountUpdateParameters.cs +++ b/Samples/3e-batch-mode/output1/Models/StorageAccountUpdateParameters.cs @@ -1,100 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The parameters to update on the account. - /// - [JsonTransformation] - public partial class StorageAccountUpdateParameters : IResource - { - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - public StorageAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the StorageAccountUpdateParameters - /// class. - /// - /// Resource tags - /// Gets or sets the account type. Note that - /// StandardZRS and PremiumLRS accounts cannot be changed to other - /// account types, and other account types cannot be changed to - /// StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', - /// 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - /// 'Premium_LRS' - /// User domain assigned to the storage - /// account. Name is the CNAME source. Only one custom domain is - /// supported per storage account at this time. To clear the existing - /// custom domain, use an empty string for the custom domain name - /// property. - public StorageAccountUpdateParameters(IDictionary tags = default(IDictionary), AccountType? accountType = default(AccountType?), CustomDomain customDomain = default(CustomDomain)) - { - Tags = tags; - AccountType = accountType; - CustomDomain = customDomain; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the account type. Note that StandardZRS and PremiumLRS - /// accounts cannot be changed to other account types, and other - /// account types cannot be changed to StandardZRS or PremiumLRS. - /// Possible values include: 'Standard_LRS', 'Standard_ZRS', - /// 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - /// - [JsonProperty(PropertyName = "properties.accountType")] - public AccountType? AccountType { get; set; } - - /// - /// Gets or sets user domain assigned to the storage account. Name is - /// the CNAME source. Only one custom domain is supported per storage - /// account at this time. To clear the existing custom domain, use an - /// empty string for the custom domain name property. - /// - [JsonProperty(PropertyName = "properties.customDomain")] - public CustomDomain CustomDomain { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CustomDomain != null) - { - CustomDomain.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/Usage.cs b/Samples/3e-batch-mode/output1/Models/Usage.cs index cc75396a7..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/Usage.cs +++ b/Samples/3e-batch-mode/output1/Models/Usage.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes Storage Resource Usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// Gets the unit of measurement. Possible values - /// include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - /// 'BytesPerSecond' - /// Gets the current count of the allocated - /// resources in the subscription. - /// Gets the maximum count of the resources that - /// can be allocated in the subscription. - /// Gets the name of the type of usage. - public Usage(UsageUnit unit, int currentValue, int limit, UsageName name) - { - Unit = unit; - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the unit of measurement. Possible values include: 'Count', - /// 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - /// - [JsonProperty(PropertyName = "unit")] - public UsageUnit Unit { get; set; } - - /// - /// Gets the current count of the allocated resources in the - /// subscription. - /// - [JsonProperty(PropertyName = "currentValue")] - public int CurrentValue { get; set; } - - /// - /// Gets the maximum count of the resources that can be allocated in - /// the subscription. - /// - [JsonProperty(PropertyName = "limit")] - public int Limit { get; set; } - - /// - /// Gets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/UsageName.cs b/Samples/3e-batch-mode/output1/Models/UsageName.cs index 8fa9f973f..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/UsageName.cs +++ b/Samples/3e-batch-mode/output1/Models/UsageName.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The Usage Names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// Gets a string describing the resource - /// name. - /// Gets a localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/Models/UsageUnit.cs b/Samples/3e-batch-mode/output1/Models/UsageUnit.cs index cf012fd42..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/Models/UsageUnit.cs +++ b/Samples/3e-batch-mode/output1/Models/UsageUnit.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for UsageUnit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum UsageUnit - { - [EnumMember(Value = "Count")] - Count, - [EnumMember(Value = "Bytes")] - Bytes, - [EnumMember(Value = "Seconds")] - Seconds, - [EnumMember(Value = "Percent")] - Percent, - [EnumMember(Value = "CountsPerSecond")] - CountsPerSecond, - [EnumMember(Value = "BytesPerSecond")] - BytesPerSecond - } - internal static class UsageUnitEnumExtension - { - internal static string ToSerializedValue(this UsageUnit? value) - { - return value == null ? null : ((UsageUnit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this UsageUnit value) - { - switch( value ) - { - case UsageUnit.Count: - return "Count"; - case UsageUnit.Bytes: - return "Bytes"; - case UsageUnit.Seconds: - return "Seconds"; - case UsageUnit.Percent: - return "Percent"; - case UsageUnit.CountsPerSecond: - return "CountsPerSecond"; - case UsageUnit.BytesPerSecond: - return "BytesPerSecond"; - } - return null; - } - - internal static UsageUnit? ParseUsageUnit(this string value) - { - switch( value ) - { - case "Count": - return UsageUnit.Count; - case "Bytes": - return UsageUnit.Bytes; - case "Seconds": - return UsageUnit.Seconds; - case "Percent": - return UsageUnit.Percent; - case "CountsPerSecond": - return UsageUnit.CountsPerSecond; - case "BytesPerSecond": - return UsageUnit.BytesPerSecond; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/StorageAccountsOperations.cs b/Samples/3e-batch-mode/output1/StorageAccountsOperations.cs index 2a6ec2694..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/StorageAccountsOperations.cs +++ b/Samples/3e-batch-mode/output1/StorageAccountsOperations.cs @@ -1,1947 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// StorageAccountsOperations operations. - /// - internal partial class StorageAccountsOperations : IServiceOperations, IStorageAccountsOperations - { - /// - /// Initializes a new instance of the StorageAccountsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal StorageAccountsOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - accountName.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(accountName != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(accountName, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetProperties", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (regenerateKey == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "regenerateKey"); - } - if (regenerateKey != null) - { - regenerateKey.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("regenerateKey", regenerateKey); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(regenerateKey != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKey, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/StorageAccountsOperationsExtensions.cs b/Samples/3e-batch-mode/output1/StorageAccountsOperationsExtensions.cs index 75d0e6448..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/StorageAccountsOperationsExtensions.cs +++ b/Samples/3e-batch-mode/output1/StorageAccountsOperationsExtensions.cs @@ -1,500 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for StorageAccountsOperations. - /// - public static partial class StorageAccountsOperationsExtensions - { - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName) - { - return operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult(); - } - - /// - /// Checks that account name is valid and is not in use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task CheckNameAvailabilityAsync(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount Create(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static void Delete(this IStorageAccountsOperations operations, string resourceGroupName, string accountName) - { - operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes a storage account in Microsoft Azure. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - public static StorageAccount GetProperties(this IStorageAccountsOperations operations, string resourceGroupName, string accountName) - { - return operations.GetPropertiesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Returns the properties for the specified storage account including but not - /// limited to name, account type, location, and account status. The ListKeys - /// operation should be used to retrieve storage keys. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The cancellation token. - /// - public static async Task GetPropertiesAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - public static StorageAccount Update(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the account type or tags for a storage account. It can also be used - /// to add a custom domain (note that custom domains cannot be added via the - /// Create operation). Only one custom domain is supported per storage account. - /// In order to replace a custom domain, the old value must be cleared before a - /// new value may be set. To clear a custom domain, simply update the custom - /// domain with empty string. Then call update again with the new cutsom domain - /// name. The update API can only be used to update one of tags, accountType, - /// or customDomain per call. To update multiple of these properties, call the - /// API multiple times with one change per call. This call does not change the - /// storage keys for the account. If you want to change storage account keys, - /// use the RegenerateKey operation. The location and name of the storage - /// account cannot be changed after creation. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to update on the account. Note that only one property can be - /// changed at a time using this API. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - public static StorageAccountKeys ListKeys(this IStorageAccountsOperations operations, string resourceGroupName, string accountName) - { - return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Lists the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the storage account. - /// - /// - /// The cancellation token. - /// - public static async Task ListKeysAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - public static IEnumerable List(this IStorageAccountsOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the subscription. Note that - /// storage keys are not returned; use the ListKeys operation for this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IStorageAccountsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - public static IEnumerable ListByResourceGroup(this IStorageAccountsOperations operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all the storage accounts available under the given resource group. - /// Note that storage keys are not returned; use the ListKeys operation for - /// this. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByResourceGroupAsync(this IStorageAccountsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - public static StorageAccountKeys RegenerateKey(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey) - { - return operations.RegenerateKeyAsync(resourceGroupName, accountName, regenerateKey).GetAwaiter().GetResult(); - } - - /// - /// Regenerates the access keys for the specified storage account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// Specifies name of the key which should be regenerated. key1 or key2 for the - /// default keys - /// - /// - /// The cancellation token. - /// - public static async Task RegenerateKeyAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, regenerateKey, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - public static StorageAccount BeginCreate(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters) - { - return operations.BeginCreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Asynchronously creates a new storage account with the specified parameters. - /// Existing accounts cannot be updated with this API and should instead use - /// the Update Storage Account API. If an account is already created and - /// subsequent PUT request is issued with exact same set of properties, then - /// HTTP 200 would be returned. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group within the user's subscription. - /// - /// - /// The name of the storage account within the specified resource group. - /// Storage account names must be between 3 and 24 characters in length and use - /// numbers and lower-case letters only. - /// - /// - /// The parameters to provide for the created account. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/StorageManagementClient.cs b/Samples/3e-batch-mode/output1/StorageManagementClient.cs index 83850d59e..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/StorageManagementClient.cs +++ b/Samples/3e-batch-mode/output1/StorageManagementClient.cs @@ -1,323 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - - /// - /// The Storage Management Client. - /// - public partial class StorageManagementClient : ServiceClient, IStorageManagementClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Gets subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client Api Version. - /// - public string ApiVersion { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Gets the IStorageAccountsOperations. - /// - public virtual IStorageAccountsOperations StorageAccounts { get; private set; } - - /// - /// Gets the IUsageOperations. - /// - public virtual IUsageOperations Usage { get; private set; } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected StorageManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected StorageManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the StorageManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public StorageManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - StorageAccounts = new StorageAccountsOperations(this); - Usage = new UsageOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2015-06-15"; - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/UsageOperations.cs b/Samples/3e-batch-mode/output1/UsageOperations.cs index 2fd6e5833..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/UsageOperations.cs +++ b/Samples/3e-batch-mode/output1/UsageOperations.cs @@ -1,229 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsageOperations operations. - /// - internal partial class UsageOperations : IServiceOperations, IUsageOperations - { - /// - /// Initializes a new instance of the UsageOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal UsageOperations(StorageManagementClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the StorageManagementClient - /// - public StorageManagementClient Client { get; private set; } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output1/UsageOperationsExtensions.cs b/Samples/3e-batch-mode/output1/UsageOperationsExtensions.cs index b479ca25a..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output1/UsageOperationsExtensions.cs +++ b/Samples/3e-batch-mode/output1/UsageOperationsExtensions.cs @@ -1,53 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Storage -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsageOperations. - /// - public static partial class UsageOperationsExtensions - { - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IEnumerable List(this IUsageOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the current usage count and the limit for the resources under the - /// subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IUsageOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/StorageAccounts.java b/Samples/3e-batch-mode/output2/StorageAccounts.java index 8cf2e1f00..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/StorageAccounts.java +++ b/Samples/3e-batch-mode/output2/StorageAccounts.java @@ -1,411 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import .models.CheckNameAvailabilityResult; -import .models.StorageAccount; -import .models.StorageAccountCheckNameAvailabilityParameters; -import .models.StorageAccountCreateParameters; -import .models.StorageAccountKeys; -import .models.StorageAccountListResult; -import .models.StorageAccountRegenerateKeyParameters; -import .models.StorageAccountUpdateParameters; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in StorageAccounts. - */ -public interface StorageAccounts { - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the CheckNameAvailabilityResult object if successful. - */ - CheckNameAvailabilityResult checkNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, final ServiceCallback serviceCallback); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - Observable checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - Observable> checkNameAvailabilityWithServiceResponseAsync(StorageAccountCheckNameAvailabilityParameters accountName); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void delete(String resourceGroupName, String accountName); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture deleteAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable deleteAsync(String resourceGroupName, String accountName); - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount getProperties(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture getPropertiesAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable getPropertiesAsync(String resourceGroupName, String accountName); - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> getPropertiesWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - StorageAccount update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters, final ServiceCallback serviceCallback); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - StorageAccountKeys listKeys(String resourceGroupName, String accountName); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable listKeysAsync(String resourceGroupName, String accountName); - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String accountName); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - StorageAccountListResult list(); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listAsync(final ServiceCallback serviceCallback); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable listAsync(); - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable> listWithServiceResponseAsync(); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - StorageAccountListResult listByResourceGroup(String resourceGroupName); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listByResourceGroupAsync(String resourceGroupName, final ServiceCallback serviceCallback); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable listByResourceGroupAsync(String resourceGroupName); - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - Observable> listByResourceGroupWithServiceResponseAsync(String resourceGroupName); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - StorageAccountKeys regenerateKey(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey, final ServiceCallback serviceCallback); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey); - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/StorageManagementClient.java b/Samples/3e-batch-mode/output2/StorageManagementClient.java index 9b02c9499..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/StorageManagementClient.java +++ b/Samples/3e-batch-mode/output2/StorageManagementClient.java @@ -1,69 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import com.microsoft.rest.RestClient; - -/** - * The interface for StorageManagementClient class. - */ -public interface StorageManagementClient { - /** - * Gets the REST client. - * - * @return the {@link RestClient} object. - */ - RestClient restClient(); - - /** - * The default base URL. - */ - String DEFAULT_BASE_URL = "https://management.azure.com"; - - /** - * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. - * - * @return the subscriptionId value. - */ - String subscriptionId(); - - /** - * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. - * - * @param subscriptionId the subscriptionId value. - * @return the service client itself - */ - StorageManagementClient withSubscriptionId(String subscriptionId); - - /** - * Gets Client Api Version.. - * - * @return the apiVersion value. - */ - String apiVersion(); - - /** - * Sets Client Api Version.. - * - * @param apiVersion the apiVersion value. - * @return the service client itself - */ - StorageManagementClient withApiVersion(String apiVersion); - - /** - * Gets the StorageAccounts object to access its operations. - * @return the StorageAccounts object. - */ - StorageAccounts storageAccounts(); - - /** - * Gets the Usages object to access its operations. - * @return the Usages object. - */ - Usages usages(); - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/Usages.java b/Samples/3e-batch-mode/output2/Usages.java index 51d136391..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/Usages.java +++ b/Samples/3e-batch-mode/output2/Usages.java @@ -1,57 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage; - -import .models.UsageListResult; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Usages. - */ -public interface Usages { - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the UsageListResult object if successful. - */ - UsageListResult list(); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture listAsync(final ServiceCallback serviceCallback); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - Observable listAsync(); - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - Observable> listWithServiceResponseAsync(); - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/implementation/StorageAccountsImpl.java b/Samples/3e-batch-mode/output2/implementation/StorageAccountsImpl.java index fadfb694e..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/implementation/StorageAccountsImpl.java +++ b/Samples/3e-batch-mode/output2/implementation/StorageAccountsImpl.java @@ -1,867 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import retrofit2.Retrofit; -import .StorageAccounts; -import .models.CheckNameAvailabilityResult; -import .models.StorageAccount; -import .models.StorageAccountCheckNameAvailabilityParameters; -import .models.StorageAccountCreateParameters; -import .models.StorageAccountKeys; -import .models.StorageAccountListResult; -import .models.StorageAccountRegenerateKeyParameters; -import .models.StorageAccountUpdateParameters; -import com.google.common.reflect.TypeToken; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.Validator; -import java.io.IOException; -import okhttp3.ResponseBody; -import retrofit2.http.Body; -import retrofit2.http.GET; -import retrofit2.http.Headers; -import retrofit2.http.HTTP; -import retrofit2.http.PATCH; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.http.PUT; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in StorageAccounts. - */ -public class StorageAccountsImpl implements StorageAccounts { - /** The Retrofit service to perform REST calls. */ - private StorageAccountsService service; - /** The service client containing this operation class. */ - private StorageManagementClientImpl client; - - /** - * Initializes an instance of StorageAccounts. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public StorageAccountsImpl(Retrofit retrofit, StorageManagementClientImpl client) { - this.service = retrofit.create(StorageAccountsService.class); - this.client = client; - } - - /** - * The interface defining all the services for StorageAccounts to be - * used by Retrofit to perform actually REST calls. - */ - interface StorageAccountsService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts checkNameAvailability" }) - @POST("subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") - Observable> checkNameAvailability(@Path("subscriptionId") String subscriptionId, @Body StorageAccountCheckNameAvailabilityParameters accountName, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts create" }) - @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> create(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountCreateParameters parameters, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts delete" }) - @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", method = "DELETE", hasBody = true) - Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts getProperties" }) - @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> getProperties(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts update" }) - @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") - Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountUpdateParameters parameters, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts listKeys" }) - @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") - Observable> listKeys(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts list" }) - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") - Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts listByResourceGroup" }) - @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") - Observable> listByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .StorageAccounts regenerateKey" }) - @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") - Observable> regenerateKey(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountRegenerateKeyParameters regenerateKey, @Query("api-version") String apiVersion); - - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the CheckNameAvailabilityResult object if successful. - */ - public CheckNameAvailabilityResult checkNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName) { - return checkNameAvailabilityWithServiceResponseAsync(accountName).toBlocking().single().body(); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(checkNameAvailabilityWithServiceResponseAsync(accountName), serviceCallback); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - public Observable checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName) { - return checkNameAvailabilityWithServiceResponseAsync(accountName).map(new Func1, CheckNameAvailabilityResult>() { - @Override - public CheckNameAvailabilityResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Checks that account name is valid and is not in use. - * - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the CheckNameAvailabilityResult object - */ - public Observable> checkNameAvailabilityWithServiceResponseAsync(StorageAccountCheckNameAvailabilityParameters accountName) { - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(accountName); - return service.checkNameAvailability(this.client.subscriptionId(), accountName, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = checkNameAvailabilityDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse checkNameAvailabilityDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body(); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to provide for the created account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (parameters == null) { - throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(parameters); - return service.create(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse createDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .register(202, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void delete(String resourceGroupName, String accountName) { - deleteWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture deleteAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable deleteAsync(String resourceGroupName, String accountName) { - return deleteWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Deletes a storage account in Microsoft Azure. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.delete(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse deleteDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .register(204, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount getProperties(String resourceGroupName, String accountName) { - return getPropertiesWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture getPropertiesAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(getPropertiesWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable getPropertiesAsync(String resourceGroupName, String accountName) { - return getPropertiesWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> getPropertiesWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.getProperties(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getPropertiesDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse getPropertiesDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccount object if successful. - */ - public StorageAccount update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body(); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, StorageAccount>() { - @Override - public StorageAccount call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccount object - */ - public Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (parameters == null) { - throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(parameters); - return service.update(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse updateDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - public StorageAccountKeys listKeys(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listKeysWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable listKeysAsync(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, StorageAccountKeys>() { - @Override - public StorageAccountKeys call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Lists the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group. - * @param accountName The name of the storage account. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String accountName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.listKeys(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listKeysDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listKeysDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - public StorageAccountListResult list() { - return listWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listAsync(final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable listAsync() { - return listWithServiceResponseAsync().map(new Func1, StorageAccountListResult>() { - @Override - public StorageAccountListResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable> listWithServiceResponseAsync() { - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.list(this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountListResult object if successful. - */ - public StorageAccountListResult listByResourceGroup(String resourceGroupName) { - return listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body(); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listByResourceGroupAsync(String resourceGroupName, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listByResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable listByResourceGroupAsync(String resourceGroupName) { - return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1, StorageAccountListResult>() { - @Override - public StorageAccountListResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountListResult object - */ - public Observable> listByResourceGroupWithServiceResponseAsync(String resourceGroupName) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listByResourceGroupDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listByResourceGroupDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the StorageAccountKeys object if successful. - */ - public StorageAccountKeys regenerateKey(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey).toBlocking().single().body(); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey), serviceCallback); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, regenerateKey).map(new Func1, StorageAccountKeys>() { - @Override - public StorageAccountKeys call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Regenerates the access keys for the specified storage account. - * - * @param resourceGroupName The name of the resource group within the user's subscription. - * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. - * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the StorageAccountKeys object - */ - public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (regenerateKey == null) { - throw new IllegalArgumentException("Parameter regenerateKey is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - Validator.validate(regenerateKey); - return service.regenerateKey(resourceGroupName, accountName, this.client.subscriptionId(), regenerateKey, this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = regenerateKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse regenerateKeyDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/implementation/StorageManagementClientImpl.java b/Samples/3e-batch-mode/output2/implementation/StorageManagementClientImpl.java index 4e34e5f66..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/implementation/StorageManagementClientImpl.java +++ b/Samples/3e-batch-mode/output2/implementation/StorageManagementClientImpl.java @@ -1,148 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import .StorageManagementClient; -import .StorageAccounts; -import .Usages; -import com.microsoft.rest.ServiceClient; -import com.microsoft.rest.RestClient; -import okhttp3.OkHttpClient; -import retrofit2.Retrofit; - -/** - * Initializes a new instance of the StorageManagementClient class. - */ -public class StorageManagementClientImpl extends ServiceClient implements StorageManagementClient { - - /** Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. */ - private String subscriptionId; - - /** - * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - * - * @return the subscriptionId value. - */ - public String subscriptionId() { - return this.subscriptionId; - } - - /** - * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - * - * @param subscriptionId the subscriptionId value. - * @return the service client itself - */ - public StorageManagementClientImpl withSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - return this; - } - - /** Client Api Version. */ - private String apiVersion; - - /** - * Gets Client Api Version. - * - * @return the apiVersion value. - */ - public String apiVersion() { - return this.apiVersion; - } - - /** - * Sets Client Api Version. - * - * @param apiVersion the apiVersion value. - * @return the service client itself - */ - public StorageManagementClientImpl withApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - return this; - } - - /** - * The StorageAccounts object to access its operations. - */ - private StorageAccounts storageAccounts; - - /** - * Gets the StorageAccounts object to access its operations. - * @return the StorageAccounts object. - */ - public StorageAccounts storageAccounts() { - return this.storageAccounts; - } - - /** - * The Usages object to access its operations. - */ - private Usages usages; - - /** - * Gets the Usages object to access its operations. - * @return the Usages object. - */ - public Usages usages() { - return this.usages; - } - - /** - * Initializes an instance of StorageManagementClient client. - */ - public StorageManagementClientImpl() { - this("https://management.azure.com"); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param baseUrl the base URL of the host - */ - public StorageManagementClientImpl(String baseUrl) { - super(baseUrl); - initialize(); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public StorageManagementClientImpl(OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - this("https://management.azure.com", clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param baseUrl the base URL of the host - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public StorageManagementClientImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - super(baseUrl, clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of StorageManagementClient client. - * - * @param restClient the REST client containing pre-configured settings - */ - public StorageManagementClientImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - private void initialize() { - this.storageAccounts = new StorageAccountsImpl(retrofit(), this); - this.usages = new UsagesImpl(retrofit(), this); - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/implementation/UsagesImpl.java b/Samples/3e-batch-mode/output2/implementation/UsagesImpl.java index 8b5576b13..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/implementation/UsagesImpl.java +++ b/Samples/3e-batch-mode/output2/implementation/UsagesImpl.java @@ -1,130 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.implementation; - -import retrofit2.Retrofit; -import .Usages; -import .models.UsageListResult; -import com.google.common.reflect.TypeToken; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import okhttp3.ResponseBody; -import retrofit2.http.GET; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Usages. - */ -public class UsagesImpl implements Usages { - /** The Retrofit service to perform REST calls. */ - private UsagesService service; - /** The service client containing this operation class. */ - private StorageManagementClientImpl client; - - /** - * Initializes an instance of Usages. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public UsagesImpl(Retrofit retrofit, StorageManagementClientImpl client) { - this.service = retrofit.create(UsagesService.class); - this.client = client; - } - - /** - * The interface defining all the services for Usages to be - * used by Retrofit to perform actually REST calls. - */ - interface UsagesService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: .Usages list" }) - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") - Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion); - - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the UsageListResult object if successful. - */ - public UsageListResult list() { - return listWithServiceResponseAsync().toBlocking().single().body(); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture listAsync(final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - public Observable listAsync() { - return listWithServiceResponseAsync().map(new Func1, UsageListResult>() { - @Override - public UsageListResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Gets the current usage count and the limit for the resources under the subscription. - * - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the UsageListResult object - */ - public Observable> listWithServiceResponseAsync() { - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - return service.list(this.client.subscriptionId(), this.client.apiVersion()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = listDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse listDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/implementation/package-info.java b/Samples/3e-batch-mode/output2/implementation/package-info.java index 0c19b9bfc..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/implementation/package-info.java +++ b/Samples/3e-batch-mode/output2/implementation/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage.implementation; +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/AccountStatus.java b/Samples/3e-batch-mode/output2/models/AccountStatus.java index 20ee2a21e..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/AccountStatus.java +++ b/Samples/3e-batch-mode/output2/models/AccountStatus.java @@ -1,51 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for AccountStatus. - */ -public enum AccountStatus { - /** Enum value Available. */ - AVAILABLE("Available"), - - /** Enum value Unavailable. */ - UNAVAILABLE("Unavailable"); - - /** The actual serialized value for a AccountStatus instance. */ - private String value; - - AccountStatus(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AccountStatus instance. - * - * @param value the serialized value to parse. - * @return the parsed AccountStatus object, or null if unable to parse. - */ - @JsonCreator - public static AccountStatus fromString(String value) { - AccountStatus[] items = AccountStatus.values(); - for (AccountStatus item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/AccountType.java b/Samples/3e-batch-mode/output2/models/AccountType.java index d01ec02b5..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/AccountType.java +++ b/Samples/3e-batch-mode/output2/models/AccountType.java @@ -1,60 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for AccountType. - */ -public enum AccountType { - /** Enum value Standard_LRS. */ - STANDARD_LRS("Standard_LRS"), - - /** Enum value Standard_ZRS. */ - STANDARD_ZRS("Standard_ZRS"), - - /** Enum value Standard_GRS. */ - STANDARD_GRS("Standard_GRS"), - - /** Enum value Standard_RAGRS. */ - STANDARD_RAGRS("Standard_RAGRS"), - - /** Enum value Premium_LRS. */ - PREMIUM_LRS("Premium_LRS"); - - /** The actual serialized value for a AccountType instance. */ - private String value; - - AccountType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AccountType instance. - * - * @param value the serialized value to parse. - * @return the parsed AccountType object, or null if unable to parse. - */ - @JsonCreator - public static AccountType fromString(String value) { - AccountType[] items = AccountType.values(); - for (AccountType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/CheckNameAvailabilityResult.java b/Samples/3e-batch-mode/output2/models/CheckNameAvailabilityResult.java index 5a0f4514a..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/CheckNameAvailabilityResult.java +++ b/Samples/3e-batch-mode/output2/models/CheckNameAvailabilityResult.java @@ -1,97 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The CheckNameAvailability operation response. - */ -public class CheckNameAvailabilityResult { - /** - * Gets a boolean value that indicates whether the name is available for - * you to use. If true, the name is available. If false, the name has - * already been taken or invalid and cannot be used. - */ - @JsonProperty(value = "nameAvailable") - private Boolean nameAvailable; - - /** - * Gets the reason that a storage account name could not be used. The - * Reason element is only returned if NameAvailable is false. Possible - * values include: 'AccountNameInvalid', 'AlreadyExists'. - */ - @JsonProperty(value = "reason") - private Reason reason; - - /** - * Gets an error message explaining the Reason value in more detail. - */ - @JsonProperty(value = "message") - private String message; - - /** - * Get the nameAvailable value. - * - * @return the nameAvailable value - */ - public Boolean nameAvailable() { - return this.nameAvailable; - } - - /** - * Set the nameAvailable value. - * - * @param nameAvailable the nameAvailable value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withNameAvailable(Boolean nameAvailable) { - this.nameAvailable = nameAvailable; - return this; - } - - /** - * Get the reason value. - * - * @return the reason value - */ - public Reason reason() { - return this.reason; - } - - /** - * Set the reason value. - * - * @param reason the reason value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withReason(Reason reason) { - this.reason = reason; - return this; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } - - /** - * Set the message value. - * - * @param message the message value to set - * @return the CheckNameAvailabilityResult object itself. - */ - public CheckNameAvailabilityResult withMessage(String message) { - this.message = message; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/CustomDomain.java b/Samples/3e-batch-mode/output2/models/CustomDomain.java index f7e791460..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/CustomDomain.java +++ b/Samples/3e-batch-mode/output2/models/CustomDomain.java @@ -1,69 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The custom domain assigned to this storage account. This can be set via - * Update. - */ -public class CustomDomain { - /** - * Gets or sets the custom domain name. Name is the CNAME source. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * Indicates whether indirect CName validation is enabled. Default value is - * false. This should only be set on updates. - */ - @JsonProperty(value = "useSubDomain") - private Boolean useSubDomain; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the CustomDomain object itself. - */ - public CustomDomain withName(String name) { - this.name = name; - return this; - } - - /** - * Get the useSubDomain value. - * - * @return the useSubDomain value - */ - public Boolean useSubDomain() { - return this.useSubDomain; - } - - /** - * Set the useSubDomain value. - * - * @param useSubDomain the useSubDomain value to set - * @return the CustomDomain object itself. - */ - public CustomDomain withUseSubDomain(Boolean useSubDomain) { - this.useSubDomain = useSubDomain; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/Endpoints.java b/Samples/3e-batch-mode/output2/models/Endpoints.java index 4359afdea..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/Endpoints.java +++ b/Samples/3e-batch-mode/output2/models/Endpoints.java @@ -1,120 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The URIs that are used to perform a retrieval of a public blob, queue or - * table object. - */ -public class Endpoints { - /** - * Gets the blob endpoint. - */ - @JsonProperty(value = "blob") - private String blob; - - /** - * Gets the queue endpoint. - */ - @JsonProperty(value = "queue") - private String queue; - - /** - * Gets the table endpoint. - */ - @JsonProperty(value = "table") - private String table; - - /** - * Gets the file endpoint. - */ - @JsonProperty(value = "file") - private String file; - - /** - * Get the blob value. - * - * @return the blob value - */ - public String blob() { - return this.blob; - } - - /** - * Set the blob value. - * - * @param blob the blob value to set - * @return the Endpoints object itself. - */ - public Endpoints withBlob(String blob) { - this.blob = blob; - return this; - } - - /** - * Get the queue value. - * - * @return the queue value - */ - public String queue() { - return this.queue; - } - - /** - * Set the queue value. - * - * @param queue the queue value to set - * @return the Endpoints object itself. - */ - public Endpoints withQueue(String queue) { - this.queue = queue; - return this; - } - - /** - * Get the table value. - * - * @return the table value - */ - public String table() { - return this.table; - } - - /** - * Set the table value. - * - * @param table the table value to set - * @return the Endpoints object itself. - */ - public Endpoints withTable(String table) { - this.table = table; - return this; - } - - /** - * Get the file value. - * - * @return the file value - */ - public String file() { - return this.file; - } - - /** - * Set the file value. - * - * @param file the file value to set - * @return the Endpoints object itself. - */ - public Endpoints withFile(String file) { - this.file = file; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/ProvisioningState.java b/Samples/3e-batch-mode/output2/models/ProvisioningState.java index 215602add..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/ProvisioningState.java +++ b/Samples/3e-batch-mode/output2/models/ProvisioningState.java @@ -1,54 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ProvisioningState. - */ -public enum ProvisioningState { - /** Enum value Creating. */ - CREATING("Creating"), - - /** Enum value ResolvingDNS. */ - RESOLVING_DNS("ResolvingDNS"), - - /** Enum value Succeeded. */ - SUCCEEDED("Succeeded"); - - /** The actual serialized value for a ProvisioningState instance. */ - private String value; - - ProvisioningState(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ProvisioningState instance. - * - * @param value the serialized value to parse. - * @return the parsed ProvisioningState object, or null if unable to parse. - */ - @JsonCreator - public static ProvisioningState fromString(String value) { - ProvisioningState[] items = ProvisioningState.values(); - for (ProvisioningState item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/Reason.java b/Samples/3e-batch-mode/output2/models/Reason.java index e1fbd1391..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/Reason.java +++ b/Samples/3e-batch-mode/output2/models/Reason.java @@ -1,51 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for Reason. - */ -public enum Reason { - /** Enum value AccountNameInvalid. */ - ACCOUNT_NAME_INVALID("AccountNameInvalid"), - - /** Enum value AlreadyExists. */ - ALREADY_EXISTS("AlreadyExists"); - - /** The actual serialized value for a Reason instance. */ - private String value; - - Reason(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a Reason instance. - * - * @param value the serialized value to parse. - * @return the parsed Reason object, or null if unable to parse. - */ - @JsonCreator - public static Reason fromString(String value) { - Reason[] items = Reason.values(); - for (Reason item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/Resource.java b/Samples/3e-batch-mode/output2/models/Resource.java index 4a819e1d5..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/Resource.java +++ b/Samples/3e-batch-mode/output2/models/Resource.java @@ -1,113 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Resource model. - */ -public class Resource { - /** - * Resource Id. - */ - @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) - private String id; - - /** - * Resource name. - */ - @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) - private String name; - - /** - * Resource type. - */ - @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) - private String type; - - /** - * Resource location. - */ - @JsonProperty(value = "location") - private String location; - - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Get the location value. - * - * @return the location value - */ - public String location() { - return this.location; - } - - /** - * Set the location value. - * - * @param location the location value to set - * @return the Resource object itself. - */ - public Resource withLocation(String location) { - this.location = location; - return this; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the Resource object itself. - */ - public Resource withTags(Map tags) { - this.tags = tags; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/StorageAccount.java b/Samples/3e-batch-mode/output2/models/StorageAccount.java index 92bd44525..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/StorageAccount.java +++ b/Samples/3e-batch-mode/output2/models/StorageAccount.java @@ -1,322 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import org.joda.time.DateTime; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The storage account. - */ -@JsonFlatten -public class StorageAccount extends Resource { - /** - * Gets the status of the storage account at the time the operation was - * called. Possible values include: 'Creating', 'ResolvingDNS', - * 'Succeeded'. - */ - @JsonProperty(value = "properties.provisioningState") - private ProvisioningState provisioningState; - - /** - * Gets the type of the storage account. Possible values include: - * 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', - * 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType") - private AccountType accountType; - - /** - * Gets the URLs that are used to perform a retrieval of a public blob, - * queue or table object.Note that StandardZRS and PremiumLRS accounts only - * return the blob endpoint. - */ - @JsonProperty(value = "properties.primaryEndpoints") - private Endpoints primaryEndpoints; - - /** - * Gets the location of the primary for the storage account. - */ - @JsonProperty(value = "properties.primaryLocation") - private String primaryLocation; - - /** - * Gets the status indicating whether the primary location of the storage - * account is available or unavailable. Possible values include: - * 'Available', 'Unavailable'. - */ - @JsonProperty(value = "properties.statusOfPrimary") - private AccountStatus statusOfPrimary; - - /** - * Gets the timestamp of the most recent instance of a failover to the - * secondary location. Only the most recent timestamp is retained. This - * element is not returned if there has never been a failover instance. - * Only available if the accountType is StandardGRS or StandardRAGRS. - */ - @JsonProperty(value = "properties.lastGeoFailoverTime") - private DateTime lastGeoFailoverTime; - - /** - * Gets the location of the geo replicated secondary for the storage - * account. Only available if the accountType is StandardGRS or - * StandardRAGRS. - */ - @JsonProperty(value = "properties.secondaryLocation") - private String secondaryLocation; - - /** - * Gets the status indicating whether the secondary location of the storage - * account is available or unavailable. Only available if the accountType - * is StandardGRS or StandardRAGRS. Possible values include: 'Available', - * 'Unavailable'. - */ - @JsonProperty(value = "properties.statusOfSecondary") - private AccountStatus statusOfSecondary; - - /** - * Gets the creation date and time of the storage account in UTC. - */ - @JsonProperty(value = "properties.creationTime") - private DateTime creationTime; - - /** - * Gets the user assigned custom domain assigned to this storage account. - */ - @JsonProperty(value = "properties.customDomain") - private CustomDomain customDomain; - - /** - * Gets the URLs that are used to perform a retrieval of a public blob, - * queue or table object from the secondary location of the storage - * account. Only available if the accountType is StandardRAGRS. - */ - @JsonProperty(value = "properties.secondaryEndpoints") - private Endpoints secondaryEndpoints; - - /** - * Get the provisioningState value. - * - * @return the provisioningState value - */ - public ProvisioningState provisioningState() { - return this.provisioningState; - } - - /** - * Set the provisioningState value. - * - * @param provisioningState the provisioningState value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withProvisioningState(ProvisioningState provisioningState) { - this.provisioningState = provisioningState; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - - /** - * Get the primaryEndpoints value. - * - * @return the primaryEndpoints value - */ - public Endpoints primaryEndpoints() { - return this.primaryEndpoints; - } - - /** - * Set the primaryEndpoints value. - * - * @param primaryEndpoints the primaryEndpoints value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withPrimaryEndpoints(Endpoints primaryEndpoints) { - this.primaryEndpoints = primaryEndpoints; - return this; - } - - /** - * Get the primaryLocation value. - * - * @return the primaryLocation value - */ - public String primaryLocation() { - return this.primaryLocation; - } - - /** - * Set the primaryLocation value. - * - * @param primaryLocation the primaryLocation value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withPrimaryLocation(String primaryLocation) { - this.primaryLocation = primaryLocation; - return this; - } - - /** - * Get the statusOfPrimary value. - * - * @return the statusOfPrimary value - */ - public AccountStatus statusOfPrimary() { - return this.statusOfPrimary; - } - - /** - * Set the statusOfPrimary value. - * - * @param statusOfPrimary the statusOfPrimary value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withStatusOfPrimary(AccountStatus statusOfPrimary) { - this.statusOfPrimary = statusOfPrimary; - return this; - } - - /** - * Get the lastGeoFailoverTime value. - * - * @return the lastGeoFailoverTime value - */ - public DateTime lastGeoFailoverTime() { - return this.lastGeoFailoverTime; - } - - /** - * Set the lastGeoFailoverTime value. - * - * @param lastGeoFailoverTime the lastGeoFailoverTime value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withLastGeoFailoverTime(DateTime lastGeoFailoverTime) { - this.lastGeoFailoverTime = lastGeoFailoverTime; - return this; - } - - /** - * Get the secondaryLocation value. - * - * @return the secondaryLocation value - */ - public String secondaryLocation() { - return this.secondaryLocation; - } - - /** - * Set the secondaryLocation value. - * - * @param secondaryLocation the secondaryLocation value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withSecondaryLocation(String secondaryLocation) { - this.secondaryLocation = secondaryLocation; - return this; - } - - /** - * Get the statusOfSecondary value. - * - * @return the statusOfSecondary value - */ - public AccountStatus statusOfSecondary() { - return this.statusOfSecondary; - } - - /** - * Set the statusOfSecondary value. - * - * @param statusOfSecondary the statusOfSecondary value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withStatusOfSecondary(AccountStatus statusOfSecondary) { - this.statusOfSecondary = statusOfSecondary; - return this; - } - - /** - * Get the creationTime value. - * - * @return the creationTime value - */ - public DateTime creationTime() { - return this.creationTime; - } - - /** - * Set the creationTime value. - * - * @param creationTime the creationTime value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withCreationTime(DateTime creationTime) { - this.creationTime = creationTime; - return this; - } - - /** - * Get the customDomain value. - * - * @return the customDomain value - */ - public CustomDomain customDomain() { - return this.customDomain; - } - - /** - * Set the customDomain value. - * - * @param customDomain the customDomain value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withCustomDomain(CustomDomain customDomain) { - this.customDomain = customDomain; - return this; - } - - /** - * Get the secondaryEndpoints value. - * - * @return the secondaryEndpoints value - */ - public Endpoints secondaryEndpoints() { - return this.secondaryEndpoints; - } - - /** - * Set the secondaryEndpoints value. - * - * @param secondaryEndpoints the secondaryEndpoints value to set - * @return the StorageAccount object itself. - */ - public StorageAccount withSecondaryEndpoints(Endpoints secondaryEndpoints) { - this.secondaryEndpoints = secondaryEndpoints; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/StorageAccountCheckNameAvailabilityParameters.java b/Samples/3e-batch-mode/output2/models/StorageAccountCheckNameAvailabilityParameters.java index b34de88bf..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/StorageAccountCheckNameAvailabilityParameters.java +++ b/Samples/3e-batch-mode/output2/models/StorageAccountCheckNameAvailabilityParameters.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The StorageAccountCheckNameAvailabilityParameters model. - */ -public class StorageAccountCheckNameAvailabilityParameters { - /** - * The name property. - */ - @JsonProperty(value = "name", required = true) - private String name; - - /** - * The type property. - */ - @JsonProperty(value = "type") - private String type; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the StorageAccountCheckNameAvailabilityParameters object itself. - */ - public StorageAccountCheckNameAvailabilityParameters withName(String name) { - this.name = name; - return this; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the StorageAccountCheckNameAvailabilityParameters object itself. - */ - public StorageAccountCheckNameAvailabilityParameters withType(String type) { - this.type = type; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/StorageAccountCreateParameters.java b/Samples/3e-batch-mode/output2/models/StorageAccountCreateParameters.java index 58aa37ec1..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/StorageAccountCreateParameters.java +++ b/Samples/3e-batch-mode/output2/models/StorageAccountCreateParameters.java @@ -1,97 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The parameters to provide for the account. - */ -@JsonFlatten -public class StorageAccountCreateParameters { - /** - * Resource location. - */ - @JsonProperty(value = "location", required = true) - private String location; - - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Gets or sets the account type. Possible values include: 'Standard_LRS', - * 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType", required = true) - private AccountType accountType; - - /** - * Get the location value. - * - * @return the location value - */ - public String location() { - return this.location; - } - - /** - * Set the location value. - * - * @param location the location value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withLocation(String location) { - this.location = location; - return this; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccountCreateParameters object itself. - */ - public StorageAccountCreateParameters withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/StorageAccountKeys.java b/Samples/3e-batch-mode/output2/models/StorageAccountKeys.java index 03b769713..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/StorageAccountKeys.java +++ b/Samples/3e-batch-mode/output2/models/StorageAccountKeys.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The access keys for the storage account. - */ -public class StorageAccountKeys { - /** - * Gets the value of key 1. - */ - @JsonProperty(value = "key1") - private String key1; - - /** - * Gets the value of key 2. - */ - @JsonProperty(value = "key2") - private String key2; - - /** - * Get the key1 value. - * - * @return the key1 value - */ - public String key1() { - return this.key1; - } - - /** - * Set the key1 value. - * - * @param key1 the key1 value to set - * @return the StorageAccountKeys object itself. - */ - public StorageAccountKeys withKey1(String key1) { - this.key1 = key1; - return this; - } - - /** - * Get the key2 value. - * - * @return the key2 value - */ - public String key2() { - return this.key2; - } - - /** - * Set the key2 value. - * - * @param key2 the key2 value to set - * @return the StorageAccountKeys object itself. - */ - public StorageAccountKeys withKey2(String key2) { - this.key2 = key2; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/StorageAccountListResult.java b/Samples/3e-batch-mode/output2/models/StorageAccountListResult.java index 214b14455..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/StorageAccountListResult.java +++ b/Samples/3e-batch-mode/output2/models/StorageAccountListResult.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The list storage accounts operation response. - */ -public class StorageAccountListResult { - /** - * Gets the list of storage accounts and their properties. - */ - @JsonProperty(value = "value") - private List value; - - /** - * Get the value value. - * - * @return the value value - */ - public List value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the StorageAccountListResult object itself. - */ - public StorageAccountListResult withValue(List value) { - this.value = value; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/StorageAccountRegenerateKeyParameters.java b/Samples/3e-batch-mode/output2/models/StorageAccountRegenerateKeyParameters.java index 90892708f..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/StorageAccountRegenerateKeyParameters.java +++ b/Samples/3e-batch-mode/output2/models/StorageAccountRegenerateKeyParameters.java @@ -1,41 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The StorageAccountRegenerateKeyParameters model. - */ -public class StorageAccountRegenerateKeyParameters { - /** - * The keyName property. - */ - @JsonProperty(value = "keyName", required = true) - private String keyName; - - /** - * Get the keyName value. - * - * @return the keyName value - */ - public String keyName() { - return this.keyName; - } - - /** - * Set the keyName value. - * - * @param keyName the keyName value to set - * @return the StorageAccountRegenerateKeyParameters object itself. - */ - public StorageAccountRegenerateKeyParameters withKeyName(String keyName) { - this.keyName = keyName; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/StorageAccountUpdateParameters.java b/Samples/3e-batch-mode/output2/models/StorageAccountUpdateParameters.java index d1958668c..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/StorageAccountUpdateParameters.java +++ b/Samples/3e-batch-mode/output2/models/StorageAccountUpdateParameters.java @@ -1,103 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * The parameters to update on the account. - */ -@JsonFlatten -public class StorageAccountUpdateParameters { - /** - * Resource tags. - */ - @JsonProperty(value = "tags") - private Map tags; - - /** - * Gets or sets the account type. Note that StandardZRS and PremiumLRS - * accounts cannot be changed to other account types, and other account - * types cannot be changed to StandardZRS or PremiumLRS. Possible values - * include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - * 'Standard_RAGRS', 'Premium_LRS'. - */ - @JsonProperty(value = "properties.accountType") - private AccountType accountType; - - /** - * User domain assigned to the storage account. Name is the CNAME source. - * Only one custom domain is supported per storage account at this time. To - * clear the existing custom domain, use an empty string for the custom - * domain name property. - */ - @JsonProperty(value = "properties.customDomain") - private CustomDomain customDomain; - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the accountType value. - * - * @return the accountType value - */ - public AccountType accountType() { - return this.accountType; - } - - /** - * Set the accountType value. - * - * @param accountType the accountType value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withAccountType(AccountType accountType) { - this.accountType = accountType; - return this; - } - - /** - * Get the customDomain value. - * - * @return the customDomain value - */ - public CustomDomain customDomain() { - return this.customDomain; - } - - /** - * Set the customDomain value. - * - * @param customDomain the customDomain value to set - * @return the StorageAccountUpdateParameters object itself. - */ - public StorageAccountUpdateParameters withCustomDomain(CustomDomain customDomain) { - this.customDomain = customDomain; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/Usage.java b/Samples/3e-batch-mode/output2/models/Usage.java index 45b3bf140..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/Usage.java +++ b/Samples/3e-batch-mode/output2/models/Usage.java @@ -1,121 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Describes Storage Resource Usage. - */ -public class Usage { - /** - * Gets the unit of measurement. Possible values include: 'Count', 'Bytes', - * 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond'. - */ - @JsonProperty(value = "unit", required = true) - private UsageUnit unit; - - /** - * Gets the current count of the allocated resources in the subscription. - */ - @JsonProperty(value = "currentValue", required = true) - private int currentValue; - - /** - * Gets the maximum count of the resources that can be allocated in the - * subscription. - */ - @JsonProperty(value = "limit", required = true) - private int limit; - - /** - * Gets the name of the type of usage. - */ - @JsonProperty(value = "name", required = true) - private UsageName name; - - /** - * Get the unit value. - * - * @return the unit value - */ - public UsageUnit unit() { - return this.unit; - } - - /** - * Set the unit value. - * - * @param unit the unit value to set - * @return the Usage object itself. - */ - public Usage withUnit(UsageUnit unit) { - this.unit = unit; - return this; - } - - /** - * Get the currentValue value. - * - * @return the currentValue value - */ - public int currentValue() { - return this.currentValue; - } - - /** - * Set the currentValue value. - * - * @param currentValue the currentValue value to set - * @return the Usage object itself. - */ - public Usage withCurrentValue(int currentValue) { - this.currentValue = currentValue; - return this; - } - - /** - * Get the limit value. - * - * @return the limit value - */ - public int limit() { - return this.limit; - } - - /** - * Set the limit value. - * - * @param limit the limit value to set - * @return the Usage object itself. - */ - public Usage withLimit(int limit) { - this.limit = limit; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public UsageName name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Usage object itself. - */ - public Usage withName(UsageName name) { - this.name = name; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/UsageListResult.java b/Samples/3e-batch-mode/output2/models/UsageListResult.java index a70f53311..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/UsageListResult.java +++ b/Samples/3e-batch-mode/output2/models/UsageListResult.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The List Usages operation response. - */ -public class UsageListResult { - /** - * Gets or sets the list Storage Resource Usages. - */ - @JsonProperty(value = "value") - private List value; - - /** - * Get the value value. - * - * @return the value value - */ - public List value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the UsageListResult object itself. - */ - public UsageListResult withValue(List value) { - this.value = value; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/UsageName.java b/Samples/3e-batch-mode/output2/models/UsageName.java index a0f2dffd5..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/UsageName.java +++ b/Samples/3e-batch-mode/output2/models/UsageName.java @@ -1,67 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Usage Names. - */ -public class UsageName { - /** - * Gets a string describing the resource name. - */ - @JsonProperty(value = "value") - private String value; - - /** - * Gets a localized string describing the resource name. - */ - @JsonProperty(value = "localizedValue") - private String localizedValue; - - /** - * Get the value value. - * - * @return the value value - */ - public String value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the UsageName object itself. - */ - public UsageName withValue(String value) { - this.value = value; - return this; - } - - /** - * Get the localizedValue value. - * - * @return the localizedValue value - */ - public String localizedValue() { - return this.localizedValue; - } - - /** - * Set the localizedValue value. - * - * @param localizedValue the localizedValue value to set - * @return the UsageName object itself. - */ - public UsageName withLocalizedValue(String localizedValue) { - this.localizedValue = localizedValue; - return this; - } - -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/UsageUnit.java b/Samples/3e-batch-mode/output2/models/UsageUnit.java index 3c205be70..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/UsageUnit.java +++ b/Samples/3e-batch-mode/output2/models/UsageUnit.java @@ -1,63 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package storage.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for UsageUnit. - */ -public enum UsageUnit { - /** Enum value Count. */ - COUNT("Count"), - - /** Enum value Bytes. */ - BYTES("Bytes"), - - /** Enum value Seconds. */ - SECONDS("Seconds"), - - /** Enum value Percent. */ - PERCENT("Percent"), - - /** Enum value CountsPerSecond. */ - COUNTS_PER_SECOND("CountsPerSecond"), - - /** Enum value BytesPerSecond. */ - BYTES_PER_SECOND("BytesPerSecond"); - - /** The actual serialized value for a UsageUnit instance. */ - private String value; - - UsageUnit(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a UsageUnit instance. - * - * @param value the serialized value to parse. - * @return the parsed UsageUnit object, or null if unable to parse. - */ - @JsonCreator - public static UsageUnit fromString(String value) { - UsageUnit[] items = UsageUnit.values(); - for (UsageUnit item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/models/package-info.java b/Samples/3e-batch-mode/output2/models/package-info.java index 17e1cbb51..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/models/package-info.java +++ b/Samples/3e-batch-mode/output2/models/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the models classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage.models; +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output2/package-info.java b/Samples/3e-batch-mode/output2/package-info.java index 325714cc1..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output2/package-info.java +++ b/Samples/3e-batch-mode/output2/package-info.java @@ -1,9 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the classes for StorageManagementClient. - * The Storage Management Client. - */ -package storage; +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor.rb b/Samples/3e-batch-mode/output3/generated/advisor.rb index b0ba890f6..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor.rb @@ -1,61 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -require 'uri' -require 'cgi' -require 'date' -require 'json' -require 'base64' -require 'erb' -require 'securerandom' -require 'time' -require 'timeliness' -require 'faraday' -require 'faraday-cookie_jar' -require 'concurrent' -require 'ms_rest' -require 'generated/advisor/module_definition' - -module Advisor - autoload :Recommendations, 'generated/advisor/recommendations.rb' - autoload :Operations, 'generated/advisor/operations.rb' - autoload :Suppressions, 'generated/advisor/suppressions.rb' - autoload :StorageAccounts, 'generated/advisor/storage_accounts.rb' - autoload :UsageOperations, 'generated/advisor/usage_operations.rb' - autoload :ComposedCowbellClient, 'generated/advisor/composed_cowbell_client.rb' - - module Models - autoload :StorageAccountCreateParameters, 'generated/advisor/models/storage_account_create_parameters.rb' - autoload :Endpoints, 'generated/advisor/models/endpoints.rb' - autoload :ShortDescription, 'generated/advisor/models/short_description.rb' - autoload :ResourceRecommendationBaseListResult, 'generated/advisor/models/resource_recommendation_base_list_result.rb' - autoload :UsageListResult, 'generated/advisor/models/usage_list_result.rb' - autoload :OperationEntity, 'generated/advisor/models/operation_entity.rb' - autoload :CustomDomain, 'generated/advisor/models/custom_domain.rb' - autoload :Resource, 'generated/advisor/models/resource.rb' - autoload :Usage, 'generated/advisor/models/usage.rb' - autoload :StorageAccountCheckNameAvailabilityParameters, 'generated/advisor/models/storage_account_check_name_availability_parameters.rb' - autoload :StorageAccountKeys, 'generated/advisor/models/storage_account_keys.rb' - autoload :OperationDisplayInfo, 'generated/advisor/models/operation_display_info.rb' - autoload :StorageAccountListResult, 'generated/advisor/models/storage_account_list_result.rb' - autoload :SuppressionContractListResult, 'generated/advisor/models/suppression_contract_list_result.rb' - autoload :StorageAccountUpdateParameters, 'generated/advisor/models/storage_account_update_parameters.rb' - autoload :OperationEntityListResult, 'generated/advisor/models/operation_entity_list_result.rb' - autoload :StorageAccountRegenerateKeyParameters, 'generated/advisor/models/storage_account_regenerate_key_parameters.rb' - autoload :CheckNameAvailabilityResult, 'generated/advisor/models/check_name_availability_result.rb' - autoload :UsageName, 'generated/advisor/models/usage_name.rb' - autoload :ResourceRecommendationBase, 'generated/advisor/models/resource_recommendation_base.rb' - autoload :SuppressionContract, 'generated/advisor/models/suppression_contract.rb' - autoload :StorageAccount, 'generated/advisor/models/storage_account.rb' - autoload :Category, 'generated/advisor/models/category.rb' - autoload :Impact, 'generated/advisor/models/impact.rb' - autoload :Risk, 'generated/advisor/models/risk.rb' - autoload :Reason, 'generated/advisor/models/reason.rb' - autoload :AccountType, 'generated/advisor/models/account_type.rb' - autoload :ProvisioningState, 'generated/advisor/models/provisioning_state.rb' - autoload :AccountStatus, 'generated/advisor/models/account_status.rb' - autoload :UsageUnit, 'generated/advisor/models/usage_unit.rb' - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/composed_cowbell_client.rb b/Samples/3e-batch-mode/output3/generated/advisor/composed_cowbell_client.rb index 484a49e5a..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/composed_cowbell_client.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/composed_cowbell_client.rb @@ -1,127 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - # - # A service client - single point of access to the REST API. - # - class ComposedCowbellClient < MsRest::ServiceClient - include MsRest::Serialization - - # @return [String] the base URI of the service. - attr_accessor :base_url - - # @return [String] The Azure subscription ID. - attr_accessor :subscription_id - - # @return [String] Gets subscription credentials which uniquely identify - # Microsoft Azure subscription. The subscription ID forms part of the URI - # for every service call. - attr_accessor :subscription_id1 - - # @return [Recommendations] recommendations - attr_reader :recommendations - - # @return [Operations] operations - attr_reader :operations - - # @return [Suppressions] suppressions - attr_reader :suppressions - - # @return [StorageAccounts] storage_accounts - attr_reader :storage_accounts - - # @return [UsageOperations] usage_operations - attr_reader :usage_operations - - # - # Creates initializes a new instance of the ComposedCowbellClient class. - # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. - # @param base_url [String] the base URI of the service. - # @param options [Array] filters to be applied to the HTTP requests. - # - def initialize(credentials = nil, base_url = nil, options = nil) - super(credentials, options) - @base_url = base_url || 'https://management.azure.com' - - fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? - @credentials = credentials - - @recommendations = Recommendations.new(self) - @operations = Operations.new(self) - @suppressions = Suppressions.new(self) - @storage_accounts = StorageAccounts.new(self) - @usage_operations = UsageOperations.new(self) - add_telemetry - end - - # - # Makes a request and returns the body of the response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Hash{String=>String}] containing the body of the response. - # Example: - # - # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}" - # path = "/path" - # options = { - # body: request_content, - # query_params: {'api-version' => '2016-02-01'} - # } - # result = @client.make_request(:put, path, options) - # - def make_request(method, path, options = {}) - result = make_request_with_http_info(method, path, options) - result.body unless result.nil? - end - - # - # Makes a request and returns the operation response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [MsRest::HttpOperationResponse] Operation response containing the request, response and status. - # - def make_request_with_http_info(method, path, options = {}) - result = make_request_async(method, path, options).value! - result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body) - result - end - - # - # Makes a request asynchronously. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def make_request_async(method, path, options = {}) - fail ArgumentError, 'method is nil' if method.nil? - fail ArgumentError, 'path is nil' if path.nil? - - request_url = options[:base_url] || @base_url - - request_headers = @request_headers - options.merge!({headers: request_headers.merge(options[:headers] || {})}) - options.merge!({credentials: @credentials}) unless @credentials.nil? - - super(request_url, method, path, options) - end - - - private - # - # Adds telemetry information. - # - def add_telemetry - sdk_information = 'advisor' - if defined? Advisor::VERSION - sdk_information = "#{sdk_information}/#{Advisor::VERSION}" - end - add_user_agent_information(sdk_information) - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/account_status.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/account_status.rb index 8b08bb922..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/account_status.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/account_status.rb @@ -1,16 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for AccountStatus - # - module AccountStatus - Available = "Available" - Unavailable = "Unavailable" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/account_type.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/account_type.rb index 93eeef6d9..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/account_type.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/account_type.rb @@ -1,19 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for AccountType - # - module AccountType - StandardLRS = "Standard_LRS" - StandardZRS = "Standard_ZRS" - StandardGRS = "Standard_GRS" - StandardRAGRS = "Standard_RAGRS" - PremiumLRS = "Premium_LRS" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/category.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/category.rb index 82398bf95..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/category.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/category.rb @@ -1,18 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for Category - # - module Category - HighAvailability = "HighAvailability" - Security = "Security" - Performance = "Performance" - Cost = "Cost" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/check_name_availability_result.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/check_name_availability_result.rb index 26412354e..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/check_name_availability_result.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/check_name_availability_result.rb @@ -1,67 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The CheckNameAvailability operation response. - # - class CheckNameAvailabilityResult - # @return [Boolean] Gets a boolean value that indicates whether the name - # is available for you to use. If true, the name is available. If false, - # the name has already been taken or invalid and cannot be used. - attr_accessor :name_available - - # @return [Reason] Gets the reason that a storage account name could not - # be used. The Reason element is only returned if NameAvailable is false. - # Possible values include: 'AccountNameInvalid', 'AlreadyExists' - attr_accessor :reason - - # @return [String] Gets an error message explaining the Reason value in - # more detail. - attr_accessor :message - - - # - # Mapper for CheckNameAvailabilityResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'CheckNameAvailabilityResult', - type: { - name: 'Composite', - class_name: 'CheckNameAvailabilityResult', - model_properties: { - name_available: { - required: false, - serialized_name: 'nameAvailable', - type: { - name: 'Boolean' - } - }, - reason: { - required: false, - serialized_name: 'reason', - type: { - name: 'Enum', - module: 'Reason' - } - }, - message: { - required: false, - serialized_name: 'message', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/custom_domain.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/custom_domain.rb index 25a9d14a8..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/custom_domain.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/custom_domain.rb @@ -1,54 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The custom domain assigned to this storage account. This can be set via - # Update. - # - class CustomDomain - # @return [String] Gets or sets the custom domain name. Name is the CNAME - # source. - attr_accessor :name - - # @return [Boolean] Indicates whether indirect CName validation is - # enabled. Default value is false. This should only be set on updates - attr_accessor :use_sub_domain - - - # - # Mapper for CustomDomain class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'CustomDomain', - type: { - name: 'Composite', - class_name: 'CustomDomain', - model_properties: { - name: { - required: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - use_sub_domain: { - required: false, - serialized_name: 'useSubDomain', - type: { - name: 'Boolean' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/endpoints.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/endpoints.rb index 76f30a13f..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/endpoints.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/endpoints.rb @@ -1,72 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The URIs that are used to perform a retrieval of a public blob, queue or - # table object. - # - class Endpoints - # @return [String] Gets the blob endpoint. - attr_accessor :blob - - # @return [String] Gets the queue endpoint. - attr_accessor :queue - - # @return [String] Gets the table endpoint. - attr_accessor :table - - # @return [String] Gets the file endpoint. - attr_accessor :file - - - # - # Mapper for Endpoints class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Endpoints', - type: { - name: 'Composite', - class_name: 'Endpoints', - model_properties: { - blob: { - required: false, - serialized_name: 'blob', - type: { - name: 'String' - } - }, - queue: { - required: false, - serialized_name: 'queue', - type: { - name: 'String' - } - }, - table: { - required: false, - serialized_name: 'table', - type: { - name: 'String' - } - }, - file: { - required: false, - serialized_name: 'file', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/impact.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/impact.rb index 7b7c569e6..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/impact.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/impact.rb @@ -1,17 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for Impact - # - module Impact - High = "High" - Medium = "Medium" - Low = "Low" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/operation_display_info.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/operation_display_info.rb index ae2a82c47..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/operation_display_info.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/operation_display_info.rb @@ -1,72 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The operation supported by Advisor. - # - class OperationDisplayInfo - # @return [String] The description of the operation. - attr_accessor :description - - # @return [String] The action that users can perform, based on their - # permission level. - attr_accessor :operation - - # @return [String] Service provider: Microsoft Advisor. - attr_accessor :provider - - # @return [String] Resource on which the operation is performed. - attr_accessor :resource - - - # - # Mapper for OperationDisplayInfo class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'OperationDisplayInfo', - type: { - name: 'Composite', - class_name: 'OperationDisplayInfo', - model_properties: { - description: { - required: false, - serialized_name: 'description', - type: { - name: 'String' - } - }, - operation: { - required: false, - serialized_name: 'operation', - type: { - name: 'String' - } - }, - provider: { - required: false, - serialized_name: 'provider', - type: { - name: 'String' - } - }, - resource: { - required: false, - serialized_name: 'resource', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity.rb index 985d69a0e..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity.rb @@ -1,52 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The operation supported by Advisor. - # - class OperationEntity - # @return [String] Operation name: {provider}/{resource}/{operation}. - attr_accessor :name - - # @return [OperationDisplayInfo] The operation supported by Advisor. - attr_accessor :display - - - # - # Mapper for OperationEntity class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'OperationEntity', - type: { - name: 'Composite', - class_name: 'OperationEntity', - model_properties: { - name: { - required: false, - serialized_name: 'name', - type: { - name: 'String' - } - }, - display: { - required: false, - serialized_name: 'display', - type: { - name: 'Composite', - class_name: 'OperationDisplayInfo' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity_list_result.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity_list_result.rb index 9c041c882..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity_list_result.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/operation_entity_list_result.rb @@ -1,59 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The list of Advisor operations. - # - class OperationEntityListResult - # @return [String] The link used to get the next page of operations. - attr_accessor :next_link - - # @return [Array] The list of operations. - attr_accessor :value - - - # - # Mapper for OperationEntityListResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'OperationEntityListResult', - type: { - name: 'Composite', - class_name: 'OperationEntityListResult', - model_properties: { - next_link: { - required: false, - serialized_name: 'nextLink', - type: { - name: 'String' - } - }, - value: { - required: false, - serialized_name: 'value', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'OperationEntityElementType', - type: { - name: 'Composite', - class_name: 'OperationEntity' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/provisioning_state.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/provisioning_state.rb index b1eff579e..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/provisioning_state.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/provisioning_state.rb @@ -1,17 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for ProvisioningState - # - module ProvisioningState - Creating = "Creating" - ResolvingDNS = "ResolvingDNS" - Succeeded = "Succeeded" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/reason.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/reason.rb index 42cbe2a80..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/reason.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/reason.rb @@ -1,16 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for Reason - # - module Reason - AccountNameInvalid = "AccountNameInvalid" - AlreadyExists = "AlreadyExists" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/resource.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/resource.rb index 19945be18..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/resource.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/resource.rb @@ -1,92 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Model object. - # - # - class Resource - # @return [String] Resource Id - attr_accessor :id - - # @return [String] Resource name - attr_accessor :name - - # @return [String] Resource type - attr_accessor :type - - # @return [String] Resource location - attr_accessor :location - - # @return [Hash{String => String}] Resource tags - attr_accessor :tags - - - # - # Mapper for Resource class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Resource', - type: { - name: 'Composite', - class_name: 'Resource', - model_properties: { - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - read_only: true, - serialized_name: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base.rb index 0834cf594..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base.rb @@ -1,195 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Advisor Recommendation. - # - class ResourceRecommendationBase < Resource - # @return [Category] The category of the recommendation. Possible values - # include: 'HighAvailability', 'Security', 'Performance', 'Cost' - attr_accessor :category - - # @return [Impact] The business impact of the recommendation. Possible - # values include: 'High', 'Medium', 'Low' - attr_accessor :impact - - # @return [String] The resource type identified by Advisor. - attr_accessor :impacted_field - - # @return [String] The resource identified by Advisor. - attr_accessor :impacted_value - - # @return [DateTime] The most recent time that Advisor checked the - # validity of the recommendation. - attr_accessor :last_updated - - # @return The recommendation metadata. - attr_accessor :metadata - - # @return [String] The recommendation-type GUID. - attr_accessor :recommendation_type_id - - # @return [Risk] The potential risk of not implementing the - # recommendation. Possible values include: 'Error', 'Warning', 'None' - attr_accessor :risk - - # @return [ShortDescription] A summary of the recommendation. - attr_accessor :short_description - - # @return The list of snoozed and dismissed rules for the recommendation. - attr_accessor :suppression_ids - - - # - # Mapper for ResourceRecommendationBase class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'ResourceRecommendationBase', - type: { - name: 'Composite', - class_name: 'ResourceRecommendationBase', - model_properties: { - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - read_only: true, - serialized_name: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - category: { - required: false, - serialized_name: 'properties.category', - type: { - name: 'String' - } - }, - impact: { - required: false, - serialized_name: 'properties.impact', - type: { - name: 'String' - } - }, - impacted_field: { - required: false, - serialized_name: 'properties.impactedField', - type: { - name: 'String' - } - }, - impacted_value: { - required: false, - serialized_name: 'properties.impactedValue', - type: { - name: 'String' - } - }, - last_updated: { - required: false, - serialized_name: 'properties.lastUpdated', - type: { - name: 'DateTime' - } - }, - metadata: { - required: false, - serialized_name: 'properties.metadata', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'ObjectElementType', - type: { - name: 'Object' - } - } - } - }, - recommendation_type_id: { - required: false, - serialized_name: 'properties.recommendationTypeId', - type: { - name: 'String' - } - }, - risk: { - required: false, - serialized_name: 'properties.risk', - type: { - name: 'String' - } - }, - short_description: { - required: false, - serialized_name: 'properties.shortDescription', - type: { - name: 'Composite', - class_name: 'ShortDescription' - } - }, - suppression_ids: { - required: false, - serialized_name: 'properties.suppressionIds', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'UuidElementType', - type: { - name: 'String' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base_list_result.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base_list_result.rb index 646603cad..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base_list_result.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/resource_recommendation_base_list_result.rb @@ -1,60 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The list of Advisor recommendations. - # - class ResourceRecommendationBaseListResult - # @return [String] The link used to get the next page of recommendations. - attr_accessor :next_link - - # @return [Array] The list of - # recommendations. - attr_accessor :value - - - # - # Mapper for ResourceRecommendationBaseListResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'ResourceRecommendationBaseListResult', - type: { - name: 'Composite', - class_name: 'ResourceRecommendationBaseListResult', - model_properties: { - next_link: { - required: false, - serialized_name: 'nextLink', - type: { - name: 'String' - } - }, - value: { - required: false, - serialized_name: 'value', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'ResourceRecommendationBaseElementType', - type: { - name: 'Composite', - class_name: 'ResourceRecommendationBase' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/risk.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/risk.rb index f4092353c..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/risk.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/risk.rb @@ -1,17 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for Risk - # - module Risk - Error = "Error" - Warning = "Warning" - None = "None" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/short_description.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/short_description.rb index 59a40f2a8..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/short_description.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/short_description.rb @@ -1,53 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # A summary of the recommendation. - # - class ShortDescription - # @return [String] The issue or opportunity identified by the - # recommendation. - attr_accessor :problem - - # @return [String] The remediation action suggested by the - # recommendation. - attr_accessor :solution - - - # - # Mapper for ShortDescription class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'ShortDescription', - type: { - name: 'Composite', - class_name: 'ShortDescription', - model_properties: { - problem: { - required: false, - serialized_name: 'problem', - type: { - name: 'String' - } - }, - solution: { - required: false, - serialized_name: 'solution', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account.rb index 20466c368..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account.rb @@ -1,216 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The storage account. - # - class StorageAccount < Resource - # @return [ProvisioningState] Gets the status of the storage account at - # the time the operation was called. Possible values include: 'Creating', - # 'ResolvingDNS', 'Succeeded' - attr_accessor :provisioning_state - - # @return [AccountType] Gets the type of the storage account. Possible - # values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - # 'Standard_RAGRS', 'Premium_LRS' - attr_accessor :account_type - - # @return [Endpoints] Gets the URLs that are used to perform a retrieval - # of a public blob, queue or table object.Note that StandardZRS and - # PremiumLRS accounts only return the blob endpoint. - attr_accessor :primary_endpoints - - # @return [String] Gets the location of the primary for the storage - # account. - attr_accessor :primary_location - - # @return [AccountStatus] Gets the status indicating whether the primary - # location of the storage account is available or unavailable. Possible - # values include: 'Available', 'Unavailable' - attr_accessor :status_of_primary - - # @return [DateTime] Gets the timestamp of the most recent instance of a - # failover to the secondary location. Only the most recent timestamp is - # retained. This element is not returned if there has never been a - # failover instance. Only available if the accountType is StandardGRS or - # StandardRAGRS. - attr_accessor :last_geo_failover_time - - # @return [String] Gets the location of the geo replicated secondary for - # the storage account. Only available if the accountType is StandardGRS - # or StandardRAGRS. - attr_accessor :secondary_location - - # @return [AccountStatus] Gets the status indicating whether the - # secondary location of the storage account is available or unavailable. - # Only available if the accountType is StandardGRS or StandardRAGRS. - # Possible values include: 'Available', 'Unavailable' - attr_accessor :status_of_secondary - - # @return [DateTime] Gets the creation date and time of the storage - # account in UTC. - attr_accessor :creation_time - - # @return [CustomDomain] Gets the user assigned custom domain assigned to - # this storage account. - attr_accessor :custom_domain - - # @return [Endpoints] Gets the URLs that are used to perform a retrieval - # of a public blob, queue or table object from the secondary location of - # the storage account. Only available if the accountType is - # StandardRAGRS. - attr_accessor :secondary_endpoints - - - # - # Mapper for StorageAccount class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccount', - type: { - name: 'Composite', - class_name: 'StorageAccount', - model_properties: { - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - read_only: true, - serialized_name: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - provisioning_state: { - required: false, - serialized_name: 'properties.provisioningState', - type: { - name: 'Enum', - module: 'ProvisioningState' - } - }, - account_type: { - required: false, - serialized_name: 'properties.accountType', - type: { - name: 'Enum', - module: 'AccountType' - } - }, - primary_endpoints: { - required: false, - serialized_name: 'properties.primaryEndpoints', - type: { - name: 'Composite', - class_name: 'Endpoints' - } - }, - primary_location: { - required: false, - serialized_name: 'properties.primaryLocation', - type: { - name: 'String' - } - }, - status_of_primary: { - required: false, - serialized_name: 'properties.statusOfPrimary', - type: { - name: 'Enum', - module: 'AccountStatus' - } - }, - last_geo_failover_time: { - required: false, - serialized_name: 'properties.lastGeoFailoverTime', - type: { - name: 'DateTime' - } - }, - secondary_location: { - required: false, - serialized_name: 'properties.secondaryLocation', - type: { - name: 'String' - } - }, - status_of_secondary: { - required: false, - serialized_name: 'properties.statusOfSecondary', - type: { - name: 'Enum', - module: 'AccountStatus' - } - }, - creation_time: { - required: false, - serialized_name: 'properties.creationTime', - type: { - name: 'DateTime' - } - }, - custom_domain: { - required: false, - serialized_name: 'properties.customDomain', - type: { - name: 'Composite', - class_name: 'CustomDomain' - } - }, - secondary_endpoints: { - required: false, - serialized_name: 'properties.secondaryEndpoints', - type: { - name: 'Composite', - class_name: 'Endpoints' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_check_name_availability_parameters.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_check_name_availability_parameters.rb index b288b4aea..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_check_name_availability_parameters.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_check_name_availability_parameters.rb @@ -1,54 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Model object. - # - # - class StorageAccountCheckNameAvailabilityParameters - # @return [String] - attr_accessor :name - - # @return [String] . Default value: 'Microsoft.Storage/storageAccounts' . - attr_accessor :type - - - # - # Mapper for StorageAccountCheckNameAvailabilityParameters class as Ruby - # Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountCheckNameAvailabilityParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountCheckNameAvailabilityParameters', - model_properties: { - name: { - required: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - serialized_name: 'type', - default_value: 'Microsoft.Storage/storageAccounts', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_create_parameters.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_create_parameters.rb index a7c4de822..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_create_parameters.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_create_parameters.rb @@ -1,71 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The parameters to provide for the account. - # - class StorageAccountCreateParameters - # @return [String] Resource location - attr_accessor :location - - # @return [Hash{String => String}] Resource tags - attr_accessor :tags - - # @return [AccountType] Gets or sets the account type. Possible values - # include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', - # 'Standard_RAGRS', 'Premium_LRS' - attr_accessor :account_type - - - # - # Mapper for StorageAccountCreateParameters class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountCreateParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountCreateParameters', - model_properties: { - location: { - required: true, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - account_type: { - required: true, - serialized_name: 'properties.accountType', - type: { - name: 'Enum', - module: 'AccountType' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_keys.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_keys.rb index cbe2b2da5..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_keys.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_keys.rb @@ -1,51 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The access keys for the storage account. - # - class StorageAccountKeys - # @return [String] Gets the value of key 1. - attr_accessor :key1 - - # @return [String] Gets the value of key 2. - attr_accessor :key2 - - - # - # Mapper for StorageAccountKeys class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountKeys', - type: { - name: 'Composite', - class_name: 'StorageAccountKeys', - model_properties: { - key1: { - required: false, - serialized_name: 'key1', - type: { - name: 'String' - } - }, - key2: { - required: false, - serialized_name: 'key2', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_list_result.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_list_result.rb index fba0740cb..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_list_result.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_list_result.rb @@ -1,50 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The list storage accounts operation response. - # - class StorageAccountListResult - # @return [Array] Gets the list of storage accounts and - # their properties. - attr_accessor :value - - - # - # Mapper for StorageAccountListResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountListResult', - type: { - name: 'Composite', - class_name: 'StorageAccountListResult', - model_properties: { - value: { - required: false, - serialized_name: 'value', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'StorageAccountElementType', - type: { - name: 'Composite', - class_name: 'StorageAccount' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_regenerate_key_parameters.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_regenerate_key_parameters.rb index 266dc1187..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_regenerate_key_parameters.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_regenerate_key_parameters.rb @@ -1,42 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Model object. - # - # - class StorageAccountRegenerateKeyParameters - # @return [String] - attr_accessor :key_name - - - # - # Mapper for StorageAccountRegenerateKeyParameters class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountRegenerateKeyParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountRegenerateKeyParameters', - model_properties: { - key_name: { - required: true, - serialized_name: 'keyName', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_update_parameters.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_update_parameters.rb index d5eebb2ee..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_update_parameters.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/storage_account_update_parameters.rb @@ -1,77 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The parameters to update on the account. - # - class StorageAccountUpdateParameters - # @return [Hash{String => String}] Resource tags - attr_accessor :tags - - # @return [AccountType] Gets or sets the account type. Note that - # StandardZRS and PremiumLRS accounts cannot be changed to other account - # types, and other account types cannot be changed to StandardZRS or - # PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', - # 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - attr_accessor :account_type - - # @return [CustomDomain] User domain assigned to the storage account. - # Name is the CNAME source. Only one custom domain is supported per - # storage account at this time. To clear the existing custom domain, use - # an empty string for the custom domain name property. - attr_accessor :custom_domain - - - # - # Mapper for StorageAccountUpdateParameters class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'StorageAccountUpdateParameters', - type: { - name: 'Composite', - class_name: 'StorageAccountUpdateParameters', - model_properties: { - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - account_type: { - required: false, - serialized_name: 'properties.accountType', - type: { - name: 'Enum', - module: 'AccountType' - } - }, - custom_domain: { - required: false, - serialized_name: 'properties.customDomain', - type: { - name: 'Composite', - class_name: 'CustomDomain' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract.rb index e89f6d51b..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract.rb @@ -1,97 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The details of the snoozed or dismissed rule; for example, the duration, - # name, and GUID associated with the rule. - # - class SuppressionContract < Resource - # @return [String] The GUID of the suppression. - attr_accessor :suppression_id - - # @return [String] The duration for which the suppression is valid. - attr_accessor :ttl - - - # - # Mapper for SuppressionContract class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'SuppressionContract', - type: { - name: 'Composite', - class_name: 'SuppressionContract', - model_properties: { - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - type: { - required: false, - read_only: true, - serialized_name: 'type', - type: { - name: 'String' - } - }, - location: { - required: false, - serialized_name: 'location', - type: { - name: 'String' - } - }, - tags: { - required: false, - serialized_name: 'tags', - type: { - name: 'Dictionary', - value: { - required: false, - serialized_name: 'StringElementType', - type: { - name: 'String' - } - } - } - }, - suppression_id: { - required: false, - serialized_name: 'properties.suppressionId', - type: { - name: 'String' - } - }, - ttl: { - required: false, - serialized_name: 'properties.ttl', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract_list_result.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract_list_result.rb index fd205ce2f..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract_list_result.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/suppression_contract_list_result.rb @@ -1,59 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The list of Advisor suppressions. - # - class SuppressionContractListResult - # @return [String] The link used to get the next page of suppressions. - attr_accessor :next_link - - # @return [Array] The list of suppressions. - attr_accessor :value - - - # - # Mapper for SuppressionContractListResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'SuppressionContractListResult', - type: { - name: 'Composite', - class_name: 'SuppressionContractListResult', - model_properties: { - next_link: { - required: false, - serialized_name: 'nextLink', - type: { - name: 'String' - } - }, - value: { - required: false, - serialized_name: 'value', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'SuppressionContractElementType', - type: { - name: 'Composite', - class_name: 'SuppressionContract' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/usage.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/usage.rb index 799a96a42..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/usage.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/usage.rb @@ -1,77 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Describes Storage Resource Usage. - # - class Usage - # @return [UsageUnit] Gets the unit of measurement. Possible values - # include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', - # 'BytesPerSecond' - attr_accessor :unit - - # @return [Integer] Gets the current count of the allocated resources in - # the subscription. - attr_accessor :current_value - - # @return [Integer] Gets the maximum count of the resources that can be - # allocated in the subscription. - attr_accessor :limit - - # @return [UsageName] Gets the name of the type of usage. - attr_accessor :name - - - # - # Mapper for Usage class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'Usage', - type: { - name: 'Composite', - class_name: 'Usage', - model_properties: { - unit: { - required: true, - serialized_name: 'unit', - type: { - name: 'Enum', - module: 'UsageUnit' - } - }, - current_value: { - required: true, - serialized_name: 'currentValue', - type: { - name: 'Number' - } - }, - limit: { - required: true, - serialized_name: 'limit', - type: { - name: 'Number' - } - }, - name: { - required: true, - serialized_name: 'name', - type: { - name: 'Composite', - class_name: 'UsageName' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/usage_list_result.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/usage_list_result.rb index 22e3d3889..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/usage_list_result.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/usage_list_result.rb @@ -1,49 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The List Usages operation response. - # - class UsageListResult - # @return [Array] Gets or sets the list Storage Resource Usages. - attr_accessor :value - - - # - # Mapper for UsageListResult class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'UsageListResult', - type: { - name: 'Composite', - class_name: 'UsageListResult', - model_properties: { - value: { - required: false, - serialized_name: 'value', - type: { - name: 'Sequence', - element: { - required: false, - serialized_name: 'UsageElementType', - type: { - name: 'Composite', - class_name: 'Usage' - } - } - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/usage_name.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/usage_name.rb index 0b6fbeb67..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/usage_name.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/usage_name.rb @@ -1,51 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # The Usage Names. - # - class UsageName - # @return [String] Gets a string describing the resource name. - attr_accessor :value - - # @return [String] Gets a localized string describing the resource name. - attr_accessor :localized_value - - - # - # Mapper for UsageName class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'UsageName', - type: { - name: 'Composite', - class_name: 'UsageName', - model_properties: { - value: { - required: false, - serialized_name: 'value', - type: { - name: 'String' - } - }, - localized_value: { - required: false, - serialized_name: 'localizedValue', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/models/usage_unit.rb b/Samples/3e-batch-mode/output3/generated/advisor/models/usage_unit.rb index ba17f1236..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/models/usage_unit.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/models/usage_unit.rb @@ -1,20 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - module Models - # - # Defines values for UsageUnit - # - module UsageUnit - Count = "Count" - Bytes = "Bytes" - Seconds = "Seconds" - Percent = "Percent" - CountsPerSecond = "CountsPerSecond" - BytesPerSecond = "BytesPerSecond" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/module_definition.rb b/Samples/3e-batch-mode/output3/generated/advisor/module_definition.rb index 64988af17..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/module_definition.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/module_definition.rb @@ -1,6 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/operations.rb b/Samples/3e-batch-mode/output3/generated/advisor/operations.rb index f03434c58..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/operations.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/operations.rb @@ -1,100 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - # - # Operations - # - class Operations - - # - # Creates and initializes a new instance of the Operations class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [ComposedCowbellClient] reference to the ComposedCowbellClient - attr_reader :client - - # - # Lists all the available Advisor REST API operations. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [OperationEntityListResult] operation results. - # - def list(custom_headers = nil) - response = list_async(custom_headers).value! - response.body unless response.nil? - end - - # - # Lists all the available Advisor REST API operations. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_with_http_info(custom_headers = nil) - list_async(custom_headers).value! - end - - # - # Lists all the available Advisor REST API operations. - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_async(custom_headers = nil) - api_version = '2017-04-19' - - - request_headers = {} - path_template = 'providers/Microsoft.Advisor/operations' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::OperationEntityListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/recommendations.rb b/Samples/3e-batch-mode/output3/generated/advisor/recommendations.rb index f43c6cba0..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/recommendations.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/recommendations.rb @@ -1,361 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - # - # Recommendations - # - class Recommendations - - # - # Creates and initializes a new instance of the Recommendations class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [ComposedCowbellClient] reference to the ComposedCowbellClient - attr_reader :client - - # - # Initiates the recommendation generation or computation process for a - # subscription. This operation is asynchronous. The generated recommendations - # are stored in a cache in the Advisor service. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def generate(custom_headers = nil) - response = generate_async(custom_headers).value! - nil - end - - # - # Initiates the recommendation generation or computation process for a - # subscription. This operation is asynchronous. The generated recommendations - # are stored in a cache in the Advisor service. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def generate_with_http_info(custom_headers = nil) - generate_async(custom_headers).value! - end - - # - # Initiates the recommendation generation or computation process for a - # subscription. This operation is asynchronous. The generated recommendations - # are stored in a cache in the Advisor service. - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def generate_async(custom_headers = nil) - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2017-04-19' - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 202 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # Retrieves the status of the recommendation computation or generation process. - # Invoke this API after calling the generation recommendation. The URI of this - # API is returned in the Location field of the response header. - # - # @param operation_id The operation ID, which can be found from the Location - # field in the generate recommendation response header. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def get_generate_status(operation_id, custom_headers = nil) - response = get_generate_status_async(operation_id, custom_headers).value! - nil - end - - # - # Retrieves the status of the recommendation computation or generation process. - # Invoke this API after calling the generation recommendation. The URI of this - # API is returned in the Location field of the response header. - # - # @param operation_id The operation ID, which can be found from the Location - # field in the generate recommendation response header. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def get_generate_status_with_http_info(operation_id, custom_headers = nil) - get_generate_status_async(operation_id, custom_headers).value! - end - - # - # Retrieves the status of the recommendation computation or generation process. - # Invoke this API after calling the generation recommendation. The URI of this - # API is returned in the Location field of the response header. - # - # @param operation_id The operation ID, which can be found from the Location - # field in the generate recommendation response header. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def get_generate_status_async(operation_id, custom_headers = nil) - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'operation_id is nil' if operation_id.nil? - api_version = '2017-04-19' - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'operationId' => operation_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 202 || status_code == 204 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # Obtains cached recommendations for a subscription. The recommendations are - # generated or computed by invoking generateRecommendations. - # - # @param filter [String] The filter to apply to the recommendations. - # @param top [Integer] The number of recommendations per page if a paged - # version of this API is being used. - # @param skip_token [String] The page-continuation token to use with a paged - # version of this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ResourceRecommendationBaseListResult] operation results. - # - def list(filter = nil, top = nil, skip_token = nil, custom_headers = nil) - response = list_async(filter, top, skip_token, custom_headers).value! - response.body unless response.nil? - end - - # - # Obtains cached recommendations for a subscription. The recommendations are - # generated or computed by invoking generateRecommendations. - # - # @param filter [String] The filter to apply to the recommendations. - # @param top [Integer] The number of recommendations per page if a paged - # version of this API is being used. - # @param skip_token [String] The page-continuation token to use with a paged - # version of this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_with_http_info(filter = nil, top = nil, skip_token = nil, custom_headers = nil) - list_async(filter, top, skip_token, custom_headers).value! - end - - # - # Obtains cached recommendations for a subscription. The recommendations are - # generated or computed by invoking generateRecommendations. - # - # @param filter [String] The filter to apply to the recommendations. - # @param top [Integer] The number of recommendations per page if a paged - # version of this API is being used. - # @param skip_token [String] The page-continuation token to use with a paged - # version of this API. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_async(filter = nil, top = nil, skip_token = nil, custom_headers = nil) - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2017-04-19' - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version,'$filter' => filter,'$top' => top,'$skipToken' => skip_token}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::ResourceRecommendationBaseListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Obtains details of a cached recommendation. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ResourceRecommendationBase] operation results. - # - def get(resource_uri, recommendation_id, custom_headers = nil) - response = get_async(resource_uri, recommendation_id, custom_headers).value! - response.body unless response.nil? - end - - # - # Obtains details of a cached recommendation. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def get_with_http_info(resource_uri, recommendation_id, custom_headers = nil) - get_async(resource_uri, recommendation_id, custom_headers).value! - end - - # - # Obtains details of a cached recommendation. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def get_async(resource_uri, recommendation_id, custom_headers = nil) - fail ArgumentError, 'resource_uri is nil' if resource_uri.nil? - fail ArgumentError, 'recommendation_id is nil' if recommendation_id.nil? - api_version = '2017-04-19' - - - request_headers = {} - path_template = '{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceUri' => resource_uri,'recommendationId' => recommendation_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::ResourceRecommendationBase.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/storage_accounts.rb b/Samples/3e-batch-mode/output3/generated/advisor/storage_accounts.rb index 1200140a4..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/storage_accounts.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/storage_accounts.rb @@ -1,945 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - # - # StorageAccounts - # - class StorageAccounts - - # - # Creates and initializes a new instance of the StorageAccounts class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [ComposedCowbellClient] reference to the ComposedCowbellClient - attr_reader :client - - # - # Checks that account name is valid and is not in use. - # - # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name - # of the storage account within the specified resource group. Storage account - # names must be between 3 and 24 characters in length and use numbers and - # lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [CheckNameAvailabilityResult] operation results. - # - def check_name_availability(account_name, custom_headers = nil) - response = check_name_availability_async(account_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Checks that account name is valid and is not in use. - # - # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name - # of the storage account within the specified resource group. Storage account - # names must be between 3 and 24 characters in length and use numbers and - # lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def check_name_availability_with_http_info(account_name, custom_headers = nil) - check_name_availability_async(account_name, custom_headers).value! - end - - # - # Checks that account name is valid and is not in use. - # - # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name - # of the storage account within the specified resource group. Storage account - # names must be between 3 and 24 characters in length and use numbers and - # lower-case letters only. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def check_name_availability_async(account_name, custom_headers = nil) - fail ArgumentError, 'account_name is nil' if account_name.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Advisor::Models::StorageAccountCheckNameAvailabilityParameters.mapper() - request_content = @client.serialize(request_mapper, account_name) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::CheckNameAvailabilityResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Asynchronously creates a new storage account with the specified parameters. - # Existing accounts cannot be updated with this API and should instead use the - # Update Storage Account API. If an account is already created and subsequent - # PUT request is issued with exact same set of properties, then HTTP 200 would - # be returned. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccount] operation results. - # - def create(resource_group_name, account_name, parameters, custom_headers = nil) - response = create_async(resource_group_name, account_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Asynchronously creates a new storage account with the specified parameters. - # Existing accounts cannot be updated with this API and should instead use the - # Update Storage Account API. If an account is already created and subsequent - # PUT request is issued with exact same set of properties, then HTTP 200 would - # be returned. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def create_with_http_info(resource_group_name, account_name, parameters, custom_headers = nil) - create_async(resource_group_name, account_name, parameters, custom_headers).value! - end - - # - # Asynchronously creates a new storage account with the specified parameters. - # Existing accounts cannot be updated with this API and should instead use the - # Update Storage Account API. If an account is already created and subsequent - # PUT request is issued with exact same set of properties, then HTTP 200 would - # be returned. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountCreateParameters] The parameters to provide - # for the created account. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def create_async(resource_group_name, account_name, parameters, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, 'parameters is nil' if parameters.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Advisor::Models::StorageAccountCreateParameters.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:put, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 || status_code == 202 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::StorageAccount.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Deletes a storage account in Microsoft Azure. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def delete(resource_group_name, account_name, custom_headers = nil) - response = delete_async(resource_group_name, account_name, custom_headers).value! - nil - end - - # - # Deletes a storage account in Microsoft Azure. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def delete_with_http_info(resource_group_name, account_name, custom_headers = nil) - delete_async(resource_group_name, account_name, custom_headers).value! - end - - # - # Deletes a storage account in Microsoft Azure. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def delete_async(resource_group_name, account_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:delete, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 || status_code == 204 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # Returns the properties for the specified storage account including but not - # limited to name, account type, location, and account status. The ListKeys - # operation should be used to retrieve storage keys. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccount] operation results. - # - def get_properties(resource_group_name, account_name, custom_headers = nil) - response = get_properties_async(resource_group_name, account_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns the properties for the specified storage account including but not - # limited to name, account type, location, and account status. The ListKeys - # operation should be used to retrieve storage keys. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def get_properties_with_http_info(resource_group_name, account_name, custom_headers = nil) - get_properties_async(resource_group_name, account_name, custom_headers).value! - end - - # - # Returns the properties for the specified storage account including but not - # limited to name, account type, location, and account status. The ListKeys - # operation should be used to retrieve storage keys. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def get_properties_async(resource_group_name, account_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::StorageAccount.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Updates the account type or tags for a storage account. It can also be used - # to add a custom domain (note that custom domains cannot be added via the - # Create operation). Only one custom domain is supported per storage account. - # In order to replace a custom domain, the old value must be cleared before a - # new value may be set. To clear a custom domain, simply update the custom - # domain with empty string. Then call update again with the new cutsom domain - # name. The update API can only be used to update one of tags, accountType, or - # customDomain per call. To update multiple of these properties, call the API - # multiple times with one change per call. This call does not change the - # storage keys for the account. If you want to change storage account keys, use - # the RegenerateKey operation. The location and name of the storage account - # cannot be changed after creation. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountUpdateParameters] The parameters to update - # on the account. Note that only one property can be changed at a time using - # this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccount] operation results. - # - def update(resource_group_name, account_name, parameters, custom_headers = nil) - response = update_async(resource_group_name, account_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Updates the account type or tags for a storage account. It can also be used - # to add a custom domain (note that custom domains cannot be added via the - # Create operation). Only one custom domain is supported per storage account. - # In order to replace a custom domain, the old value must be cleared before a - # new value may be set. To clear a custom domain, simply update the custom - # domain with empty string. Then call update again with the new cutsom domain - # name. The update API can only be used to update one of tags, accountType, or - # customDomain per call. To update multiple of these properties, call the API - # multiple times with one change per call. This call does not change the - # storage keys for the account. If you want to change storage account keys, use - # the RegenerateKey operation. The location and name of the storage account - # cannot be changed after creation. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountUpdateParameters] The parameters to update - # on the account. Note that only one property can be changed at a time using - # this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def update_with_http_info(resource_group_name, account_name, parameters, custom_headers = nil) - update_async(resource_group_name, account_name, parameters, custom_headers).value! - end - - # - # Updates the account type or tags for a storage account. It can also be used - # to add a custom domain (note that custom domains cannot be added via the - # Create operation). Only one custom domain is supported per storage account. - # In order to replace a custom domain, the old value must be cleared before a - # new value may be set. To clear a custom domain, simply update the custom - # domain with empty string. Then call update again with the new cutsom domain - # name. The update API can only be used to update one of tags, accountType, or - # customDomain per call. To update multiple of these properties, call the API - # multiple times with one change per call. This call does not change the - # storage keys for the account. If you want to change storage account keys, use - # the RegenerateKey operation. The location and name of the storage account - # cannot be changed after creation. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param parameters [StorageAccountUpdateParameters] The parameters to update - # on the account. Note that only one property can be changed at a time using - # this API. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def update_async(resource_group_name, account_name, parameters, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, 'parameters is nil' if parameters.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Advisor::Models::StorageAccountUpdateParameters.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:patch, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::StorageAccount.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Lists the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group. - # @param account_name [String] The name of the storage account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountKeys] operation results. - # - def list_keys(resource_group_name, account_name, custom_headers = nil) - response = list_keys_async(resource_group_name, account_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Lists the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group. - # @param account_name [String] The name of the storage account. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_keys_with_http_info(resource_group_name, account_name, custom_headers = nil) - list_keys_async(resource_group_name, account_name, custom_headers).value! - end - - # - # Lists the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group. - # @param account_name [String] The name of the storage account. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_keys_async(resource_group_name, account_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::StorageAccountKeys.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Lists all the storage accounts available under the subscription. Note that - # storage keys are not returned; use the ListKeys operation for this. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountListResult] operation results. - # - def list(custom_headers = nil) - response = list_async(custom_headers).value! - response.body unless response.nil? - end - - # - # Lists all the storage accounts available under the subscription. Note that - # storage keys are not returned; use the ListKeys operation for this. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_with_http_info(custom_headers = nil) - list_async(custom_headers).value! - end - - # - # Lists all the storage accounts available under the subscription. Note that - # storage keys are not returned; use the ListKeys operation for this. - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_async(custom_headers = nil) - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::StorageAccountListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Lists all the storage accounts available under the given resource group. Note - # that storage keys are not returned; use the ListKeys operation for this. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountListResult] operation results. - # - def list_by_resource_group(resource_group_name, custom_headers = nil) - response = list_by_resource_group_async(resource_group_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Lists all the storage accounts available under the given resource group. Note - # that storage keys are not returned; use the ListKeys operation for this. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_by_resource_group_with_http_info(resource_group_name, custom_headers = nil) - list_by_resource_group_async(resource_group_name, custom_headers).value! - end - - # - # Lists all the storage accounts available under the given resource group. Note - # that storage keys are not returned; use the ListKeys operation for this. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_by_resource_group_async(resource_group_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::StorageAccountListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Regenerates the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name - # of the key which should be regenerated. key1 or key2 for the default keys - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [StorageAccountKeys] operation results. - # - def regenerate_key(resource_group_name, account_name, regenerate_key, custom_headers = nil) - response = regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers).value! - response.body unless response.nil? - end - - # - # Regenerates the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name - # of the key which should be regenerated. key1 or key2 for the default keys - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def regenerate_key_with_http_info(resource_group_name, account_name, regenerate_key, custom_headers = nil) - regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers).value! - end - - # - # Regenerates the access keys for the specified storage account. - # - # @param resource_group_name [String] The name of the resource group within the - # user's subscription. - # @param account_name [String] The name of the storage account within the - # specified resource group. Storage account names must be between 3 and 24 - # characters in length and use numbers and lower-case letters only. - # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name - # of the key which should be regenerated. key1 or key2 for the default keys - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'account_name is nil' if account_name.nil? - fail ArgumentError, 'regenerate_key is nil' if regenerate_key.nil? - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Advisor::Models::StorageAccountRegenerateKeyParameters.mapper() - request_content = @client.serialize(request_mapper, regenerate_key) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::StorageAccountKeys.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/suppressions.rb b/Samples/3e-batch-mode/output3/generated/advisor/suppressions.rb index 02fd0de82..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/suppressions.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/suppressions.rb @@ -1,410 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - # - # Suppressions - # - class Suppressions - - # - # Creates and initializes a new instance of the Suppressions class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [ComposedCowbellClient] reference to the ComposedCowbellClient - attr_reader :client - - # - # Obtains the details of a suppression. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [SuppressionContract] operation results. - # - def get(resource_uri, recommendation_id, name, custom_headers = nil) - response = get_async(resource_uri, recommendation_id, name, custom_headers).value! - response.body unless response.nil? - end - - # - # Obtains the details of a suppression. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def get_with_http_info(resource_uri, recommendation_id, name, custom_headers = nil) - get_async(resource_uri, recommendation_id, name, custom_headers).value! - end - - # - # Obtains the details of a suppression. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def get_async(resource_uri, recommendation_id, name, custom_headers = nil) - fail ArgumentError, 'resource_uri is nil' if resource_uri.nil? - fail ArgumentError, 'recommendation_id is nil' if recommendation_id.nil? - fail ArgumentError, 'name is nil' if name.nil? - api_version = '2017-04-19' - - - request_headers = {} - path_template = '{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceUri' => resource_uri,'recommendationId' => recommendation_id,'name' => name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::SuppressionContract.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Enables the snoozed or dismissed attribute of a recommendation. The snoozed - # or dismissed attribute is referred to as a suppression. Use this API to - # create or update the snoozed or dismissed status of a recommendation. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param suppression_contract [SuppressionContract] The snoozed or dismissed - # attribute; for example, the snooze duration. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [SuppressionContract] operation results. - # - def create(resource_uri, recommendation_id, name, suppression_contract, custom_headers = nil) - response = create_async(resource_uri, recommendation_id, name, suppression_contract, custom_headers).value! - response.body unless response.nil? - end - - # - # Enables the snoozed or dismissed attribute of a recommendation. The snoozed - # or dismissed attribute is referred to as a suppression. Use this API to - # create or update the snoozed or dismissed status of a recommendation. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param suppression_contract [SuppressionContract] The snoozed or dismissed - # attribute; for example, the snooze duration. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def create_with_http_info(resource_uri, recommendation_id, name, suppression_contract, custom_headers = nil) - create_async(resource_uri, recommendation_id, name, suppression_contract, custom_headers).value! - end - - # - # Enables the snoozed or dismissed attribute of a recommendation. The snoozed - # or dismissed attribute is referred to as a suppression. Use this API to - # create or update the snoozed or dismissed status of a recommendation. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param suppression_contract [SuppressionContract] The snoozed or dismissed - # attribute; for example, the snooze duration. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def create_async(resource_uri, recommendation_id, name, suppression_contract, custom_headers = nil) - fail ArgumentError, 'resource_uri is nil' if resource_uri.nil? - fail ArgumentError, 'recommendation_id is nil' if recommendation_id.nil? - fail ArgumentError, 'name is nil' if name.nil? - fail ArgumentError, 'suppression_contract is nil' if suppression_contract.nil? - api_version = '2017-04-19' - - - request_headers = {} - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Advisor::Models::SuppressionContract.mapper() - request_content = @client.serialize(request_mapper, suppression_contract) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = '{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceUri' => resource_uri,'recommendationId' => recommendation_id,'name' => name}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:put, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::SuppressionContract.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Enables the activation of a snoozed or dismissed recommendation. The snoozed - # or dismissed attribute of a recommendation is referred to as a suppression. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def delete(resource_uri, recommendation_id, name, custom_headers = nil) - response = delete_async(resource_uri, recommendation_id, name, custom_headers).value! - nil - end - - # - # Enables the activation of a snoozed or dismissed recommendation. The snoozed - # or dismissed attribute of a recommendation is referred to as a suppression. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def delete_with_http_info(resource_uri, recommendation_id, name, custom_headers = nil) - delete_async(resource_uri, recommendation_id, name, custom_headers).value! - end - - # - # Enables the activation of a snoozed or dismissed recommendation. The snoozed - # or dismissed attribute of a recommendation is referred to as a suppression. - # - # @param resource_uri [String] The fully qualified Azure Resource Manager - # identifier of the resource to which the recommendation applies. - # @param recommendation_id [String] The recommendation ID. - # @param name [String] The name of the suppression. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def delete_async(resource_uri, recommendation_id, name, custom_headers = nil) - fail ArgumentError, 'resource_uri is nil' if resource_uri.nil? - fail ArgumentError, 'recommendation_id is nil' if recommendation_id.nil? - fail ArgumentError, 'name is nil' if name.nil? - api_version = '2017-04-19' - - - request_headers = {} - path_template = '{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceUri' => resource_uri,'recommendationId' => recommendation_id,'name' => name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:delete, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 204 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # Retrieves the list of snoozed or dismissed suppressions for a subscription. - # The snoozed or dismissed attribute of a recommendation is referred to as a - # suppression. - # - # @param top [Integer] The number of suppressions per page if a paged version - # of this API is being used. - # @param skip_token [String] The page-continuation token to use with a paged - # version of this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [SuppressionContractListResult] operation results. - # - def list(top = nil, skip_token = nil, custom_headers = nil) - response = list_async(top, skip_token, custom_headers).value! - response.body unless response.nil? - end - - # - # Retrieves the list of snoozed or dismissed suppressions for a subscription. - # The snoozed or dismissed attribute of a recommendation is referred to as a - # suppression. - # - # @param top [Integer] The number of suppressions per page if a paged version - # of this API is being used. - # @param skip_token [String] The page-continuation token to use with a paged - # version of this API. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_with_http_info(top = nil, skip_token = nil, custom_headers = nil) - list_async(top, skip_token, custom_headers).value! - end - - # - # Retrieves the list of snoozed or dismissed suppressions for a subscription. - # The snoozed or dismissed attribute of a recommendation is referred to as a - # suppression. - # - # @param top [Integer] The number of suppressions per page if a paged version - # of this API is being used. - # @param skip_token [String] The page-continuation token to use with a paged - # version of this API. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_async(top = nil, skip_token = nil, custom_headers = nil) - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2017-04-19' - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version,'$top' => top,'$skipToken' => skip_token}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::SuppressionContractListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/3e-batch-mode/output3/generated/advisor/usage_operations.rb b/Samples/3e-batch-mode/output3/generated/advisor/usage_operations.rb index 84826f56c..9d6cafc2c 100644 --- a/Samples/3e-batch-mode/output3/generated/advisor/usage_operations.rb +++ b/Samples/3e-batch-mode/output3/generated/advisor/usage_operations.rb @@ -1,105 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Advisor - # - # UsageOperations - # - class UsageOperations - - # - # Creates and initializes a new instance of the UsageOperations class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [ComposedCowbellClient] reference to the ComposedCowbellClient - attr_reader :client - - # - # Gets the current usage count and the limit for the resources under the - # subscription. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [UsageListResult] operation results. - # - def list(custom_headers = nil) - response = list_async(custom_headers).value! - response.body unless response.nil? - end - - # - # Gets the current usage count and the limit for the resources under the - # subscription. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def list_with_http_info(custom_headers = nil) - list_async(custom_headers).value! - end - - # - # Gets the current usage count and the limit for the resources under the - # subscription. - # - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def list_async(custom_headers = nil) - api_version = '2015-06-15' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - - - request_headers = {} - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Advisor::Models::UsageListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/3g-require-config/Client/SwaggerPetstore.cs b/Samples/3g-require-config/Client/SwaggerPetstore.cs index 6d8f5c437..9d6cafc2c 100644 --- a/Samples/3g-require-config/Client/SwaggerPetstore.cs +++ b/Samples/3g-require-config/Client/SwaggerPetstore.cs @@ -1,2946 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Petstore -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Threading; - using System.Threading.Tasks; - - /// - /// This is a sample server Petstore server. You can find out more about - /// Swagger at <a - /// href="http://swagger.io">http://swagger.io</a> or on - /// irc.freenode.net, #swagger. For this sample, you can use the api key - /// "special-key" to test the authorization filters - /// - public partial class SwaggerPetstore : ServiceClient, ISwaggerPetstore - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the SwaggerPetstore class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BaseUri = new System.Uri("http://petstore.swagger.io/v2"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - /// - /// Fake endpoint to test byte array in body parameter for adding a new pet to - /// the store - /// - /// - /// Pet object in the form of byte array - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddPetUsingByteArrayWithHttpMessagesAsync(string body = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "AddPetUsingByteArray", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Add a new pet to the store - /// - /// - /// Adds a new pet to the store. You may receive an HTTP invalid input if your - /// pet is invalid. - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddPetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "AddPet", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Update an existing pet - /// - /// - /// Pet object that needs to be added to the store - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UpdatePetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UpdatePet", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405 && (int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma seperated strings - /// - /// - /// Status values that need to be considered for filter - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> FindPetsByStatusWithHttpMessagesAsync(IList status = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("status", status); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "FindPetsByStatus", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByStatus").ToString(); - List _queryParameters = new List(); - if (status != null) - { - _queryParameters.Add(string.Format("status={0}", System.Uri.EscapeDataString(string.Join(",", status)))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - IList _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), null))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Finds Pets by tags - /// - /// - /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, - /// tag3 for testing. - /// - /// - /// Tags to filter by - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("tags", tags); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "FindPetsByTags", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByTags").ToString(); - List _queryParameters = new List(); - if (tags != null) - { - _queryParameters.Add(string.Format("tags={0}", System.Uri.EscapeDataString(string.Join(",", tags)))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - IList _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), null))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> FindPetsWithByteArrayWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "FindPetsWithByteArray", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - string _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Find pet by ID - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API - /// error conditions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetPetById", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - Pet _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates a pet in the store with form data - /// - /// - /// ID of pet that needs to be updated - /// - /// - /// Updated name of the pet - /// - /// - /// Updated status of the pet - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UpdatePetWithFormWithHttpMessagesAsync(string petId, string name = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (petId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "petId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("name", name); - tracingParameters.Add("status", status); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UpdatePetWithForm", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(petId)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - List> values = new List>(); - if(name != null) - { - values.Add("name", name); - } - if(status != null) - { - values.Add("status", status); - } - FormUrlEncodedContent _formContent = new FormUrlEncodedContent(values); - _httpRequest.Content = _formContent; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 405) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes a pet - /// - /// - /// Pet id to delete - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiKey", apiKey); - tracingParameters.Add("petId", petId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "DeletePet", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (apiKey != null) - { - if (_httpRequest.Headers.Contains("api_key")) - { - _httpRequest.Headers.Remove("api_key"); - } - _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// uploads an image - /// - /// - /// ID of pet to update - /// - /// - /// Additional data to pass to server - /// - /// - /// file to upload - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UploadFileWithHttpMessagesAsync(long petId, string additionalMetadata = default(string), Stream file = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("petId", petId); - tracingParameters.Add("additionalMetadata", additionalMetadata); - tracingParameters.Add("file", file); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UploadFile", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}/uploadImage").ToString(); - _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"'))); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - MultipartFormDataContent _multiPartContent = new MultipartFormDataContent(); - if (additionalMetadata != null) - { - StringContent _additionalMetadata = new StringContent(additionalMetadata, System.Text.Encoding.UTF8); - _multiPartContent.Add(_additionalMetadata, "additionalMetadata"); - } - if (file != null) - { - StreamContent _file = new StreamContent(file); - _file.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); - FileStream _fileAsFileStream = file as FileStream; - if (_fileAsFileStream != null) - { - ContentDispositionHeaderValue _contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-data"); - _contentDispositionHeaderValue.Name = "file"; - _contentDispositionHeaderValue.FileName = _fileAsFileStream.Name; - _file.Headers.ContentDisposition = _contentDispositionHeaderValue; - } - _multiPartContent.Add(_file, "file"); - } - _httpRequest.Content = _multiPartContent; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetInventory", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/inventory").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - IDictionary _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => (int?)e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Place an order for a pet - /// - /// - /// order placed for purchasing the pet - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> PlaceOrderWithHttpMessagesAsync(Order body = default(Order), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "PlaceOrder", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - Order _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other - /// values will generated exceptions - /// - /// - /// ID of pet that needs to be fetched - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (orderId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("orderId", orderId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetOrderById", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); - _url = _url.Replace("{orderId}", System.Uri.EscapeDataString(orderId)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - Order _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above - /// 1000 or nonintegers will generate API errors - /// - /// - /// ID of the order that needs to be deleted - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (orderId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("orderId", orderId); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "DeleteOrder", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); - _url = _url.Replace("{orderId}", System.Uri.EscapeDataString(orderId)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// Created user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreateUserWithHttpMessagesAsync(User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates list of users with given input array - /// - /// - /// List of user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithArrayInput", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithArray").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates list of users with given input array - /// - /// - /// List of user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CreateUsersWithListInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithListInput", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithList").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Logs user into the system - /// - /// - /// The user name for login - /// - /// - /// The password for login in clear text - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> LoginUserWithHttpMessagesAsync(string username = default(string), string password = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("password", password); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "LoginUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/login").ToString(); - List _queryParameters = new List(); - if (username != null) - { - _queryParameters.Add(string.Format("username={0}", System.Uri.EscapeDataString(username))); - } - if (password != null) - { - _queryParameters.Add(string.Format("password={0}", System.Uri.EscapeDataString(password))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - string _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Logs out current logged in user session - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "LogoutUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/logout").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if (!_httpResponse.IsSuccessStatusCode) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Get user by user name - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (username == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "username"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetUserByName", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); - _url = _url.Replace("{username}", System.Uri.EscapeDataString(username)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - User _tmp_ = null; - if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && - XmlSerialization.Root(XmlSerialization.ToDeserializer(e => User.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) - { - _result.Body = _tmp_; - } - else - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// name that need to be deleted - /// - /// - /// Updated user object - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task UpdateUserWithHttpMessagesAsync(string username, User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (username == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "username"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "UpdateUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); - _url = _url.Replace("{username}", System.Uri.EscapeDataString(username)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// - /// The name that needs to be deleted - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (username == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "username"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("username", username); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "DeleteUser", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); - _url = _url.Replace("{username}", System.Uri.EscapeDataString(username)); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 404 && (int)_statusCode != 400) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/additional-properties-boolean/Client/CowbellUniversity.cs b/Samples/test/additional-properties-boolean/Client/CowbellUniversity.cs index 813b9b97b..9d6cafc2c 100644 --- a/Samples/test/additional-properties-boolean/Client/CowbellUniversity.cs +++ b/Samples/test/additional-properties-boolean/Client/CowbellUniversity.cs @@ -1,146 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AddPropsBool -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellUniversity : ServiceClient, ICowbellUniversity - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Initializes a new instance of the CowbellUniversity class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellUniversity(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellUniversity class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellUniversity(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellUniversity class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellUniversity(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellUniversity class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellUniversity(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/additional-properties-boolean/Client/ICowbellUniversity.cs b/Samples/test/additional-properties-boolean/Client/ICowbellUniversity.cs index caa926344..9d6cafc2c 100644 --- a/Samples/test/additional-properties-boolean/Client/ICowbellUniversity.cs +++ b/Samples/test/additional-properties-boolean/Client/ICowbellUniversity.cs @@ -1,34 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AddPropsBool -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellUniversity : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/additional-properties-boolean/Client/Models/Cowbell1a.cs b/Samples/test/additional-properties-boolean/Client/Models/Cowbell1a.cs index 30f7ca741..9d6cafc2c 100644 --- a/Samples/test/additional-properties-boolean/Client/Models/Cowbell1a.cs +++ b/Samples/test/additional-properties-boolean/Client/Models/Cowbell1a.cs @@ -1,42 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AddPropsBool.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class Cowbell1a - { - /// - /// Initializes a new instance of the Cowbell1a class. - /// - public Cowbell1a() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell1a class. - /// - public Cowbell1a(string name = default(string)) - { - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/additional-properties-boolean/Client/Models/Cowbell1b.cs b/Samples/test/additional-properties-boolean/Client/Models/Cowbell1b.cs index b9d952892..9d6cafc2c 100644 --- a/Samples/test/additional-properties-boolean/Client/Models/Cowbell1b.cs +++ b/Samples/test/additional-properties-boolean/Client/Models/Cowbell1b.cs @@ -1,42 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AddPropsBool.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class Cowbell1b - { - /// - /// Initializes a new instance of the Cowbell1b class. - /// - public Cowbell1b() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell1b class. - /// - public Cowbell1b(string name = default(string)) - { - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/additional-properties-boolean/Client/Models/Cowbell2a.cs b/Samples/test/additional-properties-boolean/Client/Models/Cowbell2a.cs index d1593639e..9d6cafc2c 100644 --- a/Samples/test/additional-properties-boolean/Client/Models/Cowbell2a.cs +++ b/Samples/test/additional-properties-boolean/Client/Models/Cowbell2a.cs @@ -1,54 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AddPropsBool.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Cowbell2a - { - /// - /// Initializes a new instance of the Cowbell2a class. - /// - public Cowbell2a() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell2a class. - /// - /// Unmatched properties from the - /// message are deserialized this collection - public Cowbell2a(IDictionary additionalProperties = default(IDictionary), string name = default(string)) - { - AdditionalProperties = additionalProperties; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets unmatched properties from the message are deserialized - /// this collection - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/additional-properties-boolean/Client/Models/Cowbell2b.cs b/Samples/test/additional-properties-boolean/Client/Models/Cowbell2b.cs index 26556e855..9d6cafc2c 100644 --- a/Samples/test/additional-properties-boolean/Client/Models/Cowbell2b.cs +++ b/Samples/test/additional-properties-boolean/Client/Models/Cowbell2b.cs @@ -1,54 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace AddPropsBool.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Cowbell2b - { - /// - /// Initializes a new instance of the Cowbell2b class. - /// - public Cowbell2b() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell2b class. - /// - /// Unmatched properties from the - /// message are deserialized this collection - public Cowbell2b(IDictionary additionalProperties = default(IDictionary), string name = default(string)) - { - AdditionalProperties = additionalProperties; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets unmatched properties from the message are deserialized - /// this collection - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/empty-class/Client/ITest.cs b/Samples/test/empty-class/Client/ITest.cs index 1ad36a7fd..9d6cafc2c 100644 --- a/Samples/test/empty-class/Client/ITest.cs +++ b/Samples/test/empty-class/Client/ITest.cs @@ -1,35 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace EmptyClass -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Test operations. - /// - public partial interface ITest - { - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - Task> EmptyObjectWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/empty-class/Client/ITestAPI.cs b/Samples/test/empty-class/Client/ITestAPI.cs index a2361a323..9d6cafc2c 100644 --- a/Samples/test/empty-class/Client/ITestAPI.cs +++ b/Samples/test/empty-class/Client/ITestAPI.cs @@ -1,38 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace EmptyClass -{ - using Models; - using Newtonsoft.Json; - - /// - /// - public partial interface ITestAPI : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ITest. - /// - ITest Test { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/empty-class/Client/Models/EmptyClass.cs b/Samples/test/empty-class/Client/Models/EmptyClass.cs index a1a37d3c8..9d6cafc2c 100644 --- a/Samples/test/empty-class/Client/Models/EmptyClass.cs +++ b/Samples/test/empty-class/Client/Models/EmptyClass.cs @@ -1,28 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace EmptyClass.Models -{ - using System.Linq; - - public partial class EmptyClass - { - /// - /// Initializes a new instance of the EmptyClass class. - /// - public EmptyClass() - { - CustomInit(); - } - - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/empty-class/Client/Test.cs b/Samples/test/empty-class/Client/Test.cs index 876ab3683..9d6cafc2c 100644 --- a/Samples/test/empty-class/Client/Test.cs +++ b/Samples/test/empty-class/Client/Test.cs @@ -1,166 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace EmptyClass -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Test operations. - /// - public partial class Test : IServiceOperations, ITest - { - /// - /// Initializes a new instance of the Test class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Test(TestAPI client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the TestAPI - /// - public TestAPI Client { get; private set; } - - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> EmptyObjectWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "EmptyObject", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "test/emptyobject").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/empty-class/Client/TestAPI.cs b/Samples/test/empty-class/Client/TestAPI.cs index e1576ac44..9d6cafc2c 100644 --- a/Samples/test/empty-class/Client/TestAPI.cs +++ b/Samples/test/empty-class/Client/TestAPI.cs @@ -1,149 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace EmptyClass -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - public partial class TestAPI : ServiceClient, ITestAPI - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ITest. - /// - public virtual ITest Test { get; private set; } - - /// - /// Initializes a new instance of the TestAPI class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public TestAPI(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the TestAPI class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public TestAPI(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the TestAPI class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public TestAPI(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the TestAPI class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public TestAPI(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Test = new Test(this); - BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/empty-class/Client/TestExtensions.cs b/Samples/test/empty-class/Client/TestExtensions.cs index 691d9ec6d..9d6cafc2c 100644 --- a/Samples/test/empty-class/Client/TestExtensions.cs +++ b/Samples/test/empty-class/Client/TestExtensions.cs @@ -1,41 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace EmptyClass -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Test. - /// - public static partial class TestExtensions - { - /// - /// The operations group for this extension method. - /// - public static EmptyClass EmptyObject(this ITest operations) - { - return operations.EmptyObjectAsync().GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task EmptyObjectAsync(this ITest operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.EmptyObjectWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperations.cs b/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperations.cs index d9b9d0dce..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperations.cs +++ b/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperations.cs @@ -1,2038 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ApplicationGatewaysOperations operations. - /// - internal partial class ApplicationGatewaysOperations : IServiceOperations, IApplicationGatewaysOperations - { - /// - /// Initializes a new instance of the ApplicationGatewaysOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ApplicationGatewaysOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (applicationGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "applicationGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("applicationGatewayName", applicationGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{applicationGatewayName}", System.Uri.EscapeDataString(applicationGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/applicationGateways").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Starts the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task StartWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginStartWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task StopWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the backend health of the specified application gateway in a resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in backend - /// health. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> BackendHealthWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginBackendHealthWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, expand, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Deletes the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (applicationGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "applicationGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("applicationGatewayName", applicationGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{applicationGatewayName}", System.Uri.EscapeDataString(applicationGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (applicationGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "applicationGatewayName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("applicationGatewayName", applicationGatewayName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{applicationGatewayName}", System.Uri.EscapeDataString(applicationGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Starts the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginStartWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (applicationGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "applicationGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("applicationGatewayName", applicationGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginStart", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/start").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{applicationGatewayName}", System.Uri.EscapeDataString(applicationGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (applicationGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "applicationGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("applicationGatewayName", applicationGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginStop", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/stop").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{applicationGatewayName}", System.Uri.EscapeDataString(applicationGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the backend health of the specified application gateway in a resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in backend - /// health. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginBackendHealthWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (applicationGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "applicationGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("applicationGatewayName", applicationGatewayName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginBackendHealth", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/backendhealth").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{applicationGatewayName}", System.Uri.EscapeDataString(applicationGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperationsExtensions.cs index 7b6428e67..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/ApplicationGatewaysOperationsExtensions.cs @@ -1,605 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ApplicationGatewaysOperations. - /// - public static partial class ApplicationGatewaysOperationsExtensions - { - /// - /// Deletes the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - public static void Delete(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName) - { - operations.DeleteAsync(resourceGroupName, applicationGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - public static ApplicationGateway Get(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName) - { - return operations.GetAsync(resourceGroupName, applicationGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway operation. - /// - public static ApplicationGateway CreateOrUpdate(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, applicationGatewayName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this IApplicationGatewaysOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this IApplicationGatewaysOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this IApplicationGatewaysOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Starts the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - public static void Start(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName) - { - operations.StartAsync(resourceGroupName, applicationGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Starts the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The cancellation token. - /// - public static async Task StartAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.StartWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - public static void Stop(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName) - { - operations.StopAsync(resourceGroupName, applicationGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The cancellation token. - /// - public static async Task StopAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.StopWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the backend health of the specified application gateway in a resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in backend - /// health. - /// - public static ApplicationGatewayBackendHealth BackendHealth(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, string expand = default(string)) - { - return operations.BackendHealthAsync(resourceGroupName, applicationGatewayName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the backend health of the specified application gateway in a resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in backend - /// health. - /// - /// - /// The cancellation token. - /// - public static async Task BackendHealthAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BackendHealthWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - public static void BeginDelete(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName) - { - operations.BeginDeleteAsync(resourceGroupName, applicationGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway operation. - /// - public static ApplicationGateway BeginCreateOrUpdate(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, applicationGatewayName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Starts the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - public static void BeginStart(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName) - { - operations.BeginStartAsync(resourceGroupName, applicationGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Starts the specified application gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The cancellation token. - /// - public static async Task BeginStartAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginStartWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - public static void BeginStop(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName) - { - operations.BeginStopAsync(resourceGroupName, applicationGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The cancellation token. - /// - public static async Task BeginStopAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the backend health of the specified application gateway in a resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in backend - /// health. - /// - public static ApplicationGatewayBackendHealth BeginBackendHealth(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, string expand = default(string)) - { - return operations.BeginBackendHealthAsync(resourceGroupName, applicationGatewayName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the backend health of the specified application gateway in a resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in backend - /// health. - /// - /// - /// The cancellation token. - /// - public static async Task BeginBackendHealthAsync(this IApplicationGatewaysOperations operations, string resourceGroupName, string applicationGatewayName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginBackendHealthWithHttpMessagesAsync(resourceGroupName, applicationGatewayName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IApplicationGatewaysOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IApplicationGatewaysOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this IApplicationGatewaysOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this IApplicationGatewaysOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperations.cs b/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperations.cs index e62e63c92..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperations.cs +++ b/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperations.cs @@ -1,401 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// BgpServiceCommunitiesOperations operations. - /// - internal partial class BgpServiceCommunitiesOperations : IServiceOperations, IBgpServiceCommunitiesOperations - { - /// - /// Initializes a new instance of the BgpServiceCommunitiesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal BgpServiceCommunitiesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Gets all the available bgp service communities. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/bgpServiceCommunities").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the available bgp service communities. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperationsExtensions.cs index 199a853f7..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/BgpServiceCommunitiesOperationsExtensions.cs @@ -1,83 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for BgpServiceCommunitiesOperations. - /// - public static partial class BgpServiceCommunitiesOperationsExtensions - { - /// - /// Gets all the available bgp service communities. - /// - /// - /// The operations group for this extension method. - /// - public static IPage List(this IBgpServiceCommunitiesOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all the available bgp service communities. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IBgpServiceCommunitiesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the available bgp service communities. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IBgpServiceCommunitiesOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the available bgp service communities. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IBgpServiceCommunitiesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperations.cs b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperations.cs index 222823580..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperations.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperations.cs @@ -1,1102 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteCircuitAuthorizationsOperations operations. - /// - internal partial class ExpressRouteCircuitAuthorizationsOperations : IServiceOperations, IExpressRouteCircuitAuthorizationsOperations - { - /// - /// Initializes a new instance of the ExpressRouteCircuitAuthorizationsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ExpressRouteCircuitAuthorizationsOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified authorization from the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, circuitName, authorizationName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified authorization from the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (authorizationName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "authorizationName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("authorizationName", authorizationName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{authorizationName}", System.Uri.EscapeDataString(authorizationName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates an authorization in the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, authorizationName, authorizationParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified authorization from the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (authorizationName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "authorizationName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("authorizationName", authorizationName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{authorizationName}", System.Uri.EscapeDataString(authorizationName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates an authorization in the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (authorizationName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "authorizationName"); - } - if (authorizationParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "authorizationParameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("authorizationName", authorizationName); - tracingParameters.Add("authorizationParameters", authorizationParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{authorizationName}", System.Uri.EscapeDataString(authorizationName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(authorizationParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(authorizationParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperationsExtensions.cs index 00a99d375..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitAuthorizationsOperationsExtensions.cs @@ -1,339 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ExpressRouteCircuitAuthorizationsOperations. - /// - public static partial class ExpressRouteCircuitAuthorizationsOperationsExtensions - { - /// - /// Deletes the specified authorization from the specified express route - /// circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - public static void Delete(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName) - { - operations.DeleteAsync(resourceGroupName, circuitName, authorizationName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified authorization from the specified express route - /// circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, circuitName, authorizationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified authorization from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - public static ExpressRouteCircuitAuthorization Get(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName) - { - return operations.GetAsync(resourceGroupName, circuitName, authorizationName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified authorization from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, circuitName, authorizationName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates an authorization in the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - public static ExpressRouteCircuitAuthorization CreateOrUpdate(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, circuitName, authorizationName, authorizationParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates an authorization in the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, authorizationName, authorizationParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - public static IPage List(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName) - { - return operations.ListAsync(resourceGroupName, circuitName).GetAwaiter().GetResult(); - } - - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, circuitName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified authorization from the specified express route - /// circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - public static void BeginDelete(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName) - { - operations.BeginDeleteAsync(resourceGroupName, circuitName, authorizationName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified authorization from the specified express route - /// circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, circuitName, authorizationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates an authorization in the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - public static ExpressRouteCircuitAuthorization BeginCreateOrUpdate(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, circuitName, authorizationName, authorizationParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates an authorization in the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IExpressRouteCircuitAuthorizationsOperations operations, string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, authorizationName, authorizationParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IExpressRouteCircuitAuthorizationsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IExpressRouteCircuitAuthorizationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperations.cs b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperations.cs index 9273c7100..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperations.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperations.cs @@ -1,1100 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteCircuitPeeringsOperations operations. - /// - internal partial class ExpressRouteCircuitPeeringsOperations : IServiceOperations, IExpressRouteCircuitPeeringsOperations - { - /// - /// Initializes a new instance of the ExpressRouteCircuitPeeringsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ExpressRouteCircuitPeeringsOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified peering from the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified authorization from the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (peeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("peeringName", peeringName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a peering in the specified express route circuits. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit peering - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, peeringParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified peering from the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (peeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("peeringName", peeringName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a peering in the specified express route circuits. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit peering - /// operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (peeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); - } - if (peeringParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringParameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("peeringName", peeringName); - tracingParameters.Add("peeringParameters", peeringParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(peeringParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(peeringParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperationsExtensions.cs index 82a0ebb1e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitPeeringsOperationsExtensions.cs @@ -1,335 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ExpressRouteCircuitPeeringsOperations. - /// - public static partial class ExpressRouteCircuitPeeringsOperationsExtensions - { - /// - /// Deletes the specified peering from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - public static void Delete(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName) - { - operations.DeleteAsync(resourceGroupName, circuitName, peeringName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified peering from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified authorization from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - public static ExpressRouteCircuitPeering Get(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName) - { - return operations.GetAsync(resourceGroupName, circuitName, peeringName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified authorization from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a peering in the specified express route circuits. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit peering - /// operation. - /// - public static ExpressRouteCircuitPeering CreateOrUpdate(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, circuitName, peeringName, peeringParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a peering in the specified express route circuits. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit peering - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, peeringParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - public static IPage List(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName) - { - return operations.ListAsync(resourceGroupName, circuitName).GetAwaiter().GetResult(); - } - - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, circuitName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified peering from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - public static void BeginDelete(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName) - { - operations.BeginDeleteAsync(resourceGroupName, circuitName, peeringName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified peering from the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a peering in the specified express route circuits. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit peering - /// operation. - /// - public static ExpressRouteCircuitPeering BeginCreateOrUpdate(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, circuitName, peeringName, peeringParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a peering in the specified express route circuits. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit peering - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IExpressRouteCircuitPeeringsOperations operations, string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, peeringParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IExpressRouteCircuitPeeringsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IExpressRouteCircuitPeeringsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperations.cs b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperations.cs index 8aa7f08b1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperations.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperations.cs @@ -1,2542 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteCircuitsOperations operations. - /// - internal partial class ExpressRouteCircuitsOperations : IServiceOperations, IExpressRouteCircuitsOperations - { - /// - /// Initializes a new instance of the ExpressRouteCircuitsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ExpressRouteCircuitsOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, circuitName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets information about the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of express route circuit. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates an express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, ExpressRouteCircuit parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the currently advertised ARP table associated with the express route - /// circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> ListArpTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginListArpTableWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the currently advertised routes table associated with the express - /// route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> ListRoutesTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginListRoutesTableWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the currently advertised routes table summary associated with the - /// express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> ListRoutesTableSummaryWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginListRoutesTableSummaryWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all the stats from an express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetStatsWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetStats", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/stats").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all stats from an express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetPeeringStatsWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (peeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("peeringName", peeringName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetPeeringStats", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/stats").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteCircuits").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 202 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates an express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, ExpressRouteCircuit parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the currently advertised ARP table associated with the express route - /// circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginListArpTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (peeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); - } - if (devicePath == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "devicePath"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("peeringName", peeringName); - tracingParameters.Add("devicePath", devicePath); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginListArpTable", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/arpTables/{devicePath}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); - _url = _url.Replace("{devicePath}", System.Uri.EscapeDataString(devicePath)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the currently advertised routes table associated with the express - /// route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginListRoutesTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (peeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); - } - if (devicePath == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "devicePath"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("peeringName", peeringName); - tracingParameters.Add("devicePath", devicePath); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginListRoutesTable", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/routeTables/{devicePath}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); - _url = _url.Replace("{devicePath}", System.Uri.EscapeDataString(devicePath)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the currently advertised routes table summary associated with the - /// express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginListRoutesTableSummaryWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (circuitName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "circuitName"); - } - if (peeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); - } - if (devicePath == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "devicePath"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("circuitName", circuitName); - tracingParameters.Add("peeringName", peeringName); - tracingParameters.Add("devicePath", devicePath); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginListRoutesTableSummary", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/routeTablesSummary/{devicePath}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{circuitName}", System.Uri.EscapeDataString(circuitName)); - _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); - _url = _url.Replace("{devicePath}", System.Uri.EscapeDataString(devicePath)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperationsExtensions.cs index 6e289ddfe..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteCircuitsOperationsExtensions.cs @@ -1,771 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ExpressRouteCircuitsOperations. - /// - public static partial class ExpressRouteCircuitsOperationsExtensions - { - /// - /// Deletes the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - public static void Delete(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName) - { - operations.DeleteAsync(resourceGroupName, circuitName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, circuitName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets information about the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of express route circuit. - /// - public static ExpressRouteCircuit Get(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName) - { - return operations.GetAsync(resourceGroupName, circuitName).GetAwaiter().GetResult(); - } - - /// - /// Gets information about the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of express route circuit. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, circuitName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - public static ExpressRouteCircuit CreateOrUpdate(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, ExpressRouteCircuit parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, circuitName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, ExpressRouteCircuit parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the currently advertised ARP table associated with the express route - /// circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - public static ExpressRouteCircuitsArpTableListResult ListArpTable(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath) - { - return operations.ListArpTableAsync(resourceGroupName, circuitName, peeringName, devicePath).GetAwaiter().GetResult(); - } - - /// - /// Gets the currently advertised ARP table associated with the express route - /// circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The cancellation token. - /// - public static async Task ListArpTableAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListArpTableWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the currently advertised routes table associated with the express - /// route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - public static ExpressRouteCircuitsRoutesTableListResult ListRoutesTable(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath) - { - return operations.ListRoutesTableAsync(resourceGroupName, circuitName, peeringName, devicePath).GetAwaiter().GetResult(); - } - - /// - /// Gets the currently advertised routes table associated with the express - /// route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The cancellation token. - /// - public static async Task ListRoutesTableAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListRoutesTableWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the currently advertised routes table summary associated with the - /// express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - public static ExpressRouteCircuitsRoutesTableSummaryListResult ListRoutesTableSummary(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath) - { - return operations.ListRoutesTableSummaryAsync(resourceGroupName, circuitName, peeringName, devicePath).GetAwaiter().GetResult(); - } - - /// - /// Gets the currently advertised routes table summary associated with the - /// express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The cancellation token. - /// - public static async Task ListRoutesTableSummaryAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListRoutesTableSummaryWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the stats from an express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - public static ExpressRouteCircuitStats GetStats(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName) - { - return operations.GetStatsAsync(resourceGroupName, circuitName).GetAwaiter().GetResult(); - } - - /// - /// Gets all the stats from an express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The cancellation token. - /// - public static async Task GetStatsAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetStatsWithHttpMessagesAsync(resourceGroupName, circuitName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all stats from an express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - public static ExpressRouteCircuitStats GetPeeringStats(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName) - { - return operations.GetPeeringStatsAsync(resourceGroupName, circuitName, peeringName).GetAwaiter().GetResult(); - } - - /// - /// Gets all stats from an express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The cancellation token. - /// - public static async Task GetPeeringStatsAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetPeeringStatsWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this IExpressRouteCircuitsOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this IExpressRouteCircuitsOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this IExpressRouteCircuitsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - public static void BeginDelete(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName) - { - operations.BeginDeleteAsync(resourceGroupName, circuitName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, circuitName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - public static ExpressRouteCircuit BeginCreateOrUpdate(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, ExpressRouteCircuit parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, circuitName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates an express route circuit. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, ExpressRouteCircuit parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, circuitName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the currently advertised ARP table associated with the express route - /// circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - public static ExpressRouteCircuitsArpTableListResult BeginListArpTable(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath) - { - return operations.BeginListArpTableAsync(resourceGroupName, circuitName, peeringName, devicePath).GetAwaiter().GetResult(); - } - - /// - /// Gets the currently advertised ARP table associated with the express route - /// circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The cancellation token. - /// - public static async Task BeginListArpTableAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginListArpTableWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the currently advertised routes table associated with the express - /// route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - public static ExpressRouteCircuitsRoutesTableListResult BeginListRoutesTable(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath) - { - return operations.BeginListRoutesTableAsync(resourceGroupName, circuitName, peeringName, devicePath).GetAwaiter().GetResult(); - } - - /// - /// Gets the currently advertised routes table associated with the express - /// route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The cancellation token. - /// - public static async Task BeginListRoutesTableAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginListRoutesTableWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the currently advertised routes table summary associated with the - /// express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - public static ExpressRouteCircuitsRoutesTableSummaryListResult BeginListRoutesTableSummary(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath) - { - return operations.BeginListRoutesTableSummaryAsync(resourceGroupName, circuitName, peeringName, devicePath).GetAwaiter().GetResult(); - } - - /// - /// Gets the currently advertised routes table summary associated with the - /// express route circuit in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The cancellation token. - /// - public static async Task BeginListRoutesTableSummaryAsync(this IExpressRouteCircuitsOperations operations, string resourceGroupName, string circuitName, string peeringName, string devicePath, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginListRoutesTableSummaryWithHttpMessagesAsync(resourceGroupName, circuitName, peeringName, devicePath, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IExpressRouteCircuitsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IExpressRouteCircuitsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this IExpressRouteCircuitsOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this IExpressRouteCircuitsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperations.cs b/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperations.cs index 174ae6323..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperations.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperations.cs @@ -1,401 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteServiceProvidersOperations operations. - /// - internal partial class ExpressRouteServiceProvidersOperations : IServiceOperations, IExpressRouteServiceProvidersOperations - { - /// - /// Initializes a new instance of the ExpressRouteServiceProvidersOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ExpressRouteServiceProvidersOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Gets all the available express route service providers. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteServiceProviders").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the available express route service providers. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperationsExtensions.cs index 941d79a92..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/ExpressRouteServiceProvidersOperationsExtensions.cs @@ -1,83 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ExpressRouteServiceProvidersOperations. - /// - public static partial class ExpressRouteServiceProvidersOperationsExtensions - { - /// - /// Gets all the available express route service providers. - /// - /// - /// The operations group for this extension method. - /// - public static IPage List(this IExpressRouteServiceProvidersOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all the available express route service providers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IExpressRouteServiceProvidersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the available express route service providers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IExpressRouteServiceProvidersOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the available express route service providers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IExpressRouteServiceProvidersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IApplicationGatewaysOperations.cs b/Samples/test/end-to-end/network/Client/IApplicationGatewaysOperations.cs index c6bc79c17..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IApplicationGatewaysOperations.cs +++ b/Samples/test/end-to-end/network/Client/IApplicationGatewaysOperations.cs @@ -1,383 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ApplicationGatewaysOperations operations. - /// - public partial interface IApplicationGatewaysOperations - { - /// - /// Deletes the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Starts the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task StartWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task StopWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the backend health of the specified application gateway in a - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in - /// backend health. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BackendHealthWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Parameters supplied to the create or update application gateway - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, ApplicationGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Starts the specified application gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginStartWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Stops the specified application gateway in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the backend health of the specified application gateway in a - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the application gateway. - /// - /// - /// Expands BackendAddressPool and BackendHttpSettings referenced in - /// backend health. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginBackendHealthWithHttpMessagesAsync(string resourceGroupName, string applicationGatewayName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all application gateways in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the application gateways in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IBgpServiceCommunitiesOperations.cs b/Samples/test/end-to-end/network/Client/IBgpServiceCommunitiesOperations.cs index 9d6fa099b..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IBgpServiceCommunitiesOperations.cs +++ b/Samples/test/end-to-end/network/Client/IBgpServiceCommunitiesOperations.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// BgpServiceCommunitiesOperations operations. - /// - public partial interface IBgpServiceCommunitiesOperations - { - /// - /// Gets all the available bgp service communities. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the available bgp service communities. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IExpressRouteCircuitAuthorizationsOperations.cs b/Samples/test/end-to-end/network/Client/IExpressRouteCircuitAuthorizationsOperations.cs index 28194e2b0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IExpressRouteCircuitAuthorizationsOperations.cs +++ b/Samples/test/end-to-end/network/Client/IExpressRouteCircuitAuthorizationsOperations.cs @@ -1,217 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteCircuitAuthorizationsOperations operations. - /// - public partial interface IExpressRouteCircuitAuthorizationsOperations - { - /// - /// Deletes the specified authorization from the specified express - /// route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified authorization from the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates an authorization in the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified authorization from the specified express - /// route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates an authorization in the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the authorization. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// authorization operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string authorizationName, ExpressRouteCircuitAuthorization authorizationParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all authorizations in an express route circuit. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IExpressRouteCircuitPeeringsOperations.cs b/Samples/test/end-to-end/network/Client/IExpressRouteCircuitPeeringsOperations.cs index 629f31820..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IExpressRouteCircuitPeeringsOperations.cs +++ b/Samples/test/end-to-end/network/Client/IExpressRouteCircuitPeeringsOperations.cs @@ -1,217 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteCircuitPeeringsOperations operations. - /// - public partial interface IExpressRouteCircuitPeeringsOperations - { - /// - /// Deletes the specified peering from the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified authorization from the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a peering in the specified express route - /// circuits. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// peering operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified peering from the specified express route - /// circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a peering in the specified express route - /// circuits. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// peering operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, ExpressRouteCircuitPeering peeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all peerings in a specified express route circuit. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IExpressRouteCircuitsOperations.cs b/Samples/test/end-to-end/network/Client/IExpressRouteCircuitsOperations.cs index 8df22a1d9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IExpressRouteCircuitsOperations.cs +++ b/Samples/test/end-to-end/network/Client/IExpressRouteCircuitsOperations.cs @@ -1,481 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteCircuitsOperations operations. - /// - public partial interface IExpressRouteCircuitsOperations - { - /// - /// Deletes the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets information about the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of express route circuit. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates an express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, ExpressRouteCircuit parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the currently advertised ARP table associated with the express - /// route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListArpTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the currently advertised routes table associated with the - /// express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListRoutesTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the currently advertised routes table summary associated with - /// the express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListRoutesTableSummaryWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the stats from an express route circuit in a resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetStatsWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all stats from an express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetPeeringStatsWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string circuitName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates an express route circuit. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the circuit. - /// - /// - /// Parameters supplied to the create or update express route circuit - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string circuitName, ExpressRouteCircuit parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the currently advertised ARP table associated with the express - /// route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginListArpTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the currently advertised routes table associated with the - /// express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginListRoutesTableWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the currently advertised routes table summary associated with - /// the express route circuit in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the express route circuit. - /// - /// - /// The name of the peering. - /// - /// - /// The path of the device. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginListRoutesTableSummaryWithHttpMessagesAsync(string resourceGroupName, string circuitName, string peeringName, string devicePath, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the express route circuits in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the express route circuits in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IExpressRouteServiceProvidersOperations.cs b/Samples/test/end-to-end/network/Client/IExpressRouteServiceProvidersOperations.cs index 1ccaaa7ce..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IExpressRouteServiceProvidersOperations.cs +++ b/Samples/test/end-to-end/network/Client/IExpressRouteServiceProvidersOperations.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ExpressRouteServiceProvidersOperations operations. - /// - public partial interface IExpressRouteServiceProvidersOperations - { - /// - /// Gets all the available express route service providers. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the available express route service providers. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ILoadBalancersOperations.cs b/Samples/test/end-to-end/network/Client/ILoadBalancersOperations.cs index a6cec3d60..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ILoadBalancersOperations.cs +++ b/Samples/test/end-to-end/network/Client/ILoadBalancersOperations.cs @@ -1,238 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// LoadBalancersOperations operations. - /// - public partial interface ILoadBalancersOperations - { - /// - /// Deletes the specified load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, LoadBalancer parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, LoadBalancer parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ILocalNetworkGatewaysOperations.cs b/Samples/test/end-to-end/network/Client/ILocalNetworkGatewaysOperations.cs index e69cb6fd1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ILocalNetworkGatewaysOperations.cs +++ b/Samples/test/end-to-end/network/Client/ILocalNetworkGatewaysOperations.cs @@ -1,196 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// LocalNetworkGatewaysOperations operations. - /// - public partial interface ILocalNetworkGatewaysOperations - { - /// - /// Creates or updates a local network gateway in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified local network gateway in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified local network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a local network gateway in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified local network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/INetworkClient.cs b/Samples/test/end-to-end/network/Client/INetworkClient.cs index 124feb563..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/INetworkClient.cs +++ b/Samples/test/end-to-end/network/Client/INetworkClient.cs @@ -1,217 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// The Microsoft Azure Network management API provides a RESTful set of - /// web services that interact with Microsoft Azure Networks service to - /// manage your network resources. The API has entities that capture the - /// relationship between an end user and the Microsoft Azure Networks - /// service. - /// - public partial interface INetworkClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// The subscription credentials which uniquely identify the Microsoft - /// Azure subscription. The subscription ID forms part of the URI for - /// every service call. - /// - string SubscriptionId { get; set; } - - /// - /// Client API version. - /// - string ApiVersion { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// Gets the IApplicationGatewaysOperations. - /// - IApplicationGatewaysOperations ApplicationGateways { get; } - - /// - /// Gets the IExpressRouteCircuitAuthorizationsOperations. - /// - IExpressRouteCircuitAuthorizationsOperations ExpressRouteCircuitAuthorizations { get; } - - /// - /// Gets the IExpressRouteCircuitPeeringsOperations. - /// - IExpressRouteCircuitPeeringsOperations ExpressRouteCircuitPeerings { get; } - - /// - /// Gets the IExpressRouteCircuitsOperations. - /// - IExpressRouteCircuitsOperations ExpressRouteCircuits { get; } - - /// - /// Gets the IExpressRouteServiceProvidersOperations. - /// - IExpressRouteServiceProvidersOperations ExpressRouteServiceProviders { get; } - - /// - /// Gets the ILoadBalancersOperations. - /// - ILoadBalancersOperations LoadBalancers { get; } - - /// - /// Gets the INetworkInterfacesOperations. - /// - INetworkInterfacesOperations NetworkInterfaces { get; } - - /// - /// Gets the INetworkSecurityGroupsOperations. - /// - INetworkSecurityGroupsOperations NetworkSecurityGroups { get; } - - /// - /// Gets the ISecurityRulesOperations. - /// - ISecurityRulesOperations SecurityRules { get; } - - /// - /// Gets the INetworkWatchersOperations. - /// - INetworkWatchersOperations NetworkWatchers { get; } - - /// - /// Gets the IPacketCapturesOperations. - /// - IPacketCapturesOperations PacketCaptures { get; } - - /// - /// Gets the IPublicIPAddressesOperations. - /// - IPublicIPAddressesOperations PublicIPAddresses { get; } - - /// - /// Gets the IRouteFiltersOperations. - /// - IRouteFiltersOperations RouteFilters { get; } - - /// - /// Gets the IRouteFilterRulesOperations. - /// - IRouteFilterRulesOperations RouteFilterRules { get; } - - /// - /// Gets the IRouteTablesOperations. - /// - IRouteTablesOperations RouteTables { get; } - - /// - /// Gets the IRoutesOperations. - /// - IRoutesOperations Routes { get; } - - /// - /// Gets the IBgpServiceCommunitiesOperations. - /// - IBgpServiceCommunitiesOperations BgpServiceCommunities { get; } - - /// - /// Gets the IUsagesOperations. - /// - IUsagesOperations Usages { get; } - - /// - /// Gets the IVirtualNetworksOperations. - /// - IVirtualNetworksOperations VirtualNetworks { get; } - - /// - /// Gets the ISubnetsOperations. - /// - ISubnetsOperations Subnets { get; } - - /// - /// Gets the IVirtualNetworkPeeringsOperations. - /// - IVirtualNetworkPeeringsOperations VirtualNetworkPeerings { get; } - - /// - /// Gets the IVirtualNetworkGatewaysOperations. - /// - IVirtualNetworkGatewaysOperations VirtualNetworkGateways { get; } - - /// - /// Gets the IVirtualNetworkGatewayConnectionsOperations. - /// - IVirtualNetworkGatewayConnectionsOperations VirtualNetworkGatewayConnections { get; } - - /// - /// Gets the ILocalNetworkGatewaysOperations. - /// - ILocalNetworkGatewaysOperations LocalNetworkGateways { get; } - - /// - /// Checks whether a domain name in the cloudapp.net zone is available - /// for use. - /// - /// - /// The location of the domain name. - /// - /// - /// The domain name to be verified. It must conform to the following - /// regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - Task> CheckDnsNameAvailabilityWithHttpMessagesAsync(string location, string domainNameLabel = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/INetworkInterfacesOperations.cs b/Samples/test/end-to-end/network/Client/INetworkInterfacesOperations.cs index c621f26db..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/INetworkInterfacesOperations.cs +++ b/Samples/test/end-to-end/network/Client/INetworkInterfacesOperations.cs @@ -1,471 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// NetworkInterfacesOperations operations. - /// - public partial interface INetworkInterfacesOperations - { - /// - /// Deletes the specified network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets information about the specified network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetEffectiveRouteTableWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ListEffectiveNetworkSecurityGroupsWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets information about all network interfaces in a virtual machine - /// in a virtual machine scale set. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListVirtualMachineScaleSetVMNetworkInterfacesWithHttpMessagesAsync(string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListVirtualMachineScaleSetNetworkInterfacesWithHttpMessagesAsync(string resourceGroupName, string virtualMachineScaleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Get the specified network interface in a virtual machine scale set. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetVirtualMachineScaleSetNetworkInterfaceWithHttpMessagesAsync(string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex, string networkInterfaceName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetEffectiveRouteTableWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginListEffectiveNetworkSecurityGroupsWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets information about all network interfaces in a virtual machine - /// in a virtual machine scale set. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListVirtualMachineScaleSetVMNetworkInterfacesNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListVirtualMachineScaleSetNetworkInterfacesNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/INetworkSecurityGroupsOperations.cs b/Samples/test/end-to-end/network/Client/INetworkSecurityGroupsOperations.cs index aefed78ef..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/INetworkSecurityGroupsOperations.cs +++ b/Samples/test/end-to-end/network/Client/INetworkSecurityGroupsOperations.cs @@ -1,240 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// NetworkSecurityGroupsOperations operations. - /// - public partial interface INetworkSecurityGroupsOperations - { - /// - /// Deletes the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a network security group in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network security groups in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a network security group in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network security groups in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/INetworkWatchersOperations.cs b/Samples/test/end-to-end/network/Client/INetworkWatchersOperations.cs index cc0f42334..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/INetworkWatchersOperations.cs +++ b/Samples/test/end-to-end/network/Client/INetworkWatchersOperations.cs @@ -1,590 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// NetworkWatchersOperations operations. - /// - public partial interface INetworkWatchersOperations - { - /// - /// Creates or updates a network watcher in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the network watcher resource. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, NetworkWatcher parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified network watcher by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network watchers by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all network watchers by subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the current network topology by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the representation of topology. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetTopologyWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, TopologyParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Verify IP flow from the specified VM to a location given the - /// currently configured NSG rules. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> VerifyIPFlowWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetNextHopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, NextHopParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the configured and effective security group rules on the - /// specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetVMSecurityRulesWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetTroubleshootingWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Get the last completed troubleshooting result on a specified - /// resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting - /// result. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetTroubleshootingResultWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Configures flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> SetFlowLogConfigurationWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogInformation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetFlowLogStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Verify IP flow from the specified VM to a location given the - /// currently configured NSG rules. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginVerifyIPFlowWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetNextHopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, NextHopParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the configured and effective security group rules on the - /// specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetVMSecurityRulesWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetTroubleshootingWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Get the last completed troubleshooting result on a specified - /// resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting - /// result. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetTroubleshootingResultWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Configures flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginSetFlowLogConfigurationWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogInformation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetFlowLogStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IPacketCapturesOperations.cs b/Samples/test/end-to-end/network/Client/IPacketCapturesOperations.cs index 0c4884bb0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IPacketCapturesOperations.cs +++ b/Samples/test/end-to-end/network/Client/IPacketCapturesOperations.cs @@ -1,295 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PacketCapturesOperations operations. - /// - public partial interface IPacketCapturesOperations - { - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets a packet capture session by name. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Stops a specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task StopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Query the status of a running packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists all packet capture sessions within the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Stops a specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Query the status of a running packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IPublicIPAddressesOperations.cs b/Samples/test/end-to-end/network/Client/IPublicIPAddressesOperations.cs index dec915232..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IPublicIPAddressesOperations.cs +++ b/Samples/test/end-to-end/network/Client/IPublicIPAddressesOperations.cs @@ -1,238 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PublicIPAddressesOperations operations. - /// - public partial interface IPublicIPAddressesOperations - { - /// - /// Deletes the specified public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified public IP address in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IRouteFilterRulesOperations.cs b/Samples/test/end-to-end/network/Client/IRouteFilterRulesOperations.cs index 7b9e15ee4..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IRouteFilterRulesOperations.cs +++ b/Samples/test/end-to-end/network/Client/IRouteFilterRulesOperations.cs @@ -1,274 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RouteFilterRulesOperations operations. - /// - public partial interface IRouteFilterRulesOperations - { - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified rule from a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByRouteFilterWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByRouteFilterNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IRouteFiltersOperations.cs b/Samples/test/end-to-end/network/Client/IRouteFiltersOperations.cs index ba41b2fdf..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IRouteFiltersOperations.cs +++ b/Samples/test/end-to-end/network/Client/IRouteFiltersOperations.cs @@ -1,292 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RouteFiltersOperations operations. - /// - public partial interface IRouteFiltersOperations - { - /// - /// Deletes the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Expands referenced express route bgp peering resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route filters in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route filters in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route filters in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route filters in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IRouteTablesOperations.cs b/Samples/test/end-to-end/network/Client/IRouteTablesOperations.cs index c70094e5e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IRouteTablesOperations.cs +++ b/Samples/test/end-to-end/network/Client/IRouteTablesOperations.cs @@ -1,236 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RouteTablesOperations operations. - /// - public partial interface IRouteTablesOperations - { - /// - /// Deletes the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, RouteTable parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route tables in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route tables in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, RouteTable parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route tables in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all route tables in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IRoutesOperations.cs b/Samples/test/end-to-end/network/Client/IRoutesOperations.cs index 8d40fdb25..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IRoutesOperations.cs +++ b/Samples/test/end-to-end/network/Client/IRoutesOperations.cs @@ -1,210 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RoutesOperations operations. - /// - public partial interface IRoutesOperations - { - /// - /// Deletes the specified route from a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified route from a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Route routeParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all routes in a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, string routeTableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified route from a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Route routeParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all routes in a route table. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ISecurityRulesOperations.cs b/Samples/test/end-to-end/network/Client/ISecurityRulesOperations.cs index cf545ac73..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ISecurityRulesOperations.cs +++ b/Samples/test/end-to-end/network/Client/ISecurityRulesOperations.cs @@ -1,214 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SecurityRulesOperations operations. - /// - public partial interface ISecurityRulesOperations - { - /// - /// Deletes the specified network security rule. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Get the specified network security rule. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a security rule in the specified network - /// security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all security rules in a network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified network security rule. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a security rule in the specified network - /// security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all security rules in a network security group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/ISubnetsOperations.cs b/Samples/test/end-to-end/network/Client/ISubnetsOperations.cs index 03feb2db6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/ISubnetsOperations.cs +++ b/Samples/test/end-to-end/network/Client/ISubnetsOperations.cs @@ -1,213 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SubnetsOperations operations. - /// - public partial interface ISubnetsOperations - { - /// - /// Deletes the specified subnet. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified subnet by virtual network and resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified subnet. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IUsagesOperations.cs b/Samples/test/end-to-end/network/Client/IUsagesOperations.cs index 351ab421e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IUsagesOperations.cs +++ b/Samples/test/end-to-end/network/Client/IUsagesOperations.cs @@ -1,67 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsagesOperations operations. - /// - public partial interface IUsagesOperations - { - /// - /// Lists compute usages for a subscription. - /// - /// - /// The location where resource usage is queried. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Lists compute usages for a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewayConnectionsOperations.cs b/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewayConnectionsOperations.cs index 4fc364a8b..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewayConnectionsOperations.cs +++ b/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewayConnectionsOperations.cs @@ -1,354 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworkGatewayConnectionsOperations operations. - /// - public partial interface IVirtualNetworkGatewayConnectionsOperations - { - /// - /// Creates or updates a virtual network gateway connection in the - /// specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified virtual network gateway connection by resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the - /// virtual network gateway connection shared key for passed virtual - /// network gateway connection in the specified resource group through - /// Network resource provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway - /// connection Shared key operation throughNetwork resource provider. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> SetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The Get VirtualNetworkGatewayConnectionSharedKey operation - /// retrieves information about the specified virtual network gateway - /// connection shared key through Network resource provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection shared key name. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all - /// the virtual network gateways connections created. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets - /// the virtual network gateway connection shared key for passed - /// virtual network gateway connection in the specified resource group - /// through Network resource provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway - /// connection shared key operation through network resource provider. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ResetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a virtual network gateway connection in the - /// specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the - /// virtual network gateway connection shared key for passed virtual - /// network gateway connection in the specified resource group through - /// Network resource provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway - /// connection Shared key operation throughNetwork resource provider. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginSetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets - /// the virtual network gateway connection shared key for passed - /// virtual network gateway connection in the specified resource group - /// through Network resource provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway - /// connection shared key operation through network resource provider. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginResetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all - /// the virtual network gateways connections created. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewaysOperations.cs b/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewaysOperations.cs index 4d5197e90..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewaysOperations.cs +++ b/Samples/test/end-to-end/network/Client/IVirtualNetworkGatewaysOperations.cs @@ -1,454 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworkGatewaysOperations operations. - /// - public partial interface IVirtualNetworkGatewaysOperations - { - /// - /// Creates or updates a virtual network gateway in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified virtual network gateway by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Resets the primary of the virtual network gateway in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of - /// the active-active feature enabled gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ResetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Generates VPN client package for P2S client of the virtual network - /// gateway in the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to the generate virtual network gateway VPN - /// client package operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GeneratevpnclientpackageWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, VpnClientParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP - /// peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetBgpPeerStatusWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// This operation retrieves a list of routes the virtual network - /// gateway has learned, including routes learned from BGP peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetLearnedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// This operation retrieves a list of routes the virtual network - /// gateway is advertising to the specified peer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetAdvertisedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a virtual network gateway in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Resets the primary of the virtual network gateway in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of - /// the active-active feature enabled gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginResetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP - /// peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetBgpPeerStatusWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// This operation retrieves a list of routes the virtual network - /// gateway has learned, including routes learned from BGP peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetLearnedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// This operation retrieves a list of routes the virtual network - /// gateway is advertising to the specified peer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginGetAdvertisedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IVirtualNetworkPeeringsOperations.cs b/Samples/test/end-to-end/network/Client/IVirtualNetworkPeeringsOperations.cs index 41ecd55d3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IVirtualNetworkPeeringsOperations.cs +++ b/Samples/test/end-to-end/network/Client/IVirtualNetworkPeeringsOperations.cs @@ -1,212 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworkPeeringsOperations operations. - /// - public partial interface IVirtualNetworkPeeringsOperations - { - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified virtual network peering. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/IVirtualNetworksOperations.cs b/Samples/test/end-to-end/network/Client/IVirtualNetworksOperations.cs index 30b750e83..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/IVirtualNetworksOperations.cs +++ b/Samples/test/end-to-end/network/Client/IVirtualNetworksOperations.cs @@ -1,268 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworksOperations operations. - /// - public partial interface IVirtualNetworksOperations - { - /// - /// Deletes the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets the specified virtual network by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Expands referenced resources. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a virtual network in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network - /// operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Checks whether a private IP address is available for use. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The private IP address to be verified. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CheckIPAddressAvailabilityWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string ipAddress = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates a virtual network in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network - /// operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/LoadBalancersOperations.cs b/Samples/test/end-to-end/network/Client/LoadBalancersOperations.cs index b781fa959..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/LoadBalancersOperations.cs +++ b/Samples/test/end-to-end/network/Client/LoadBalancersOperations.cs @@ -1,1415 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// LoadBalancersOperations operations. - /// - internal partial class LoadBalancersOperations : IServiceOperations, ILoadBalancersOperations - { - /// - /// Initializes a new instance of the LoadBalancersOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal LoadBalancersOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, loadBalancerName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (loadBalancerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "loadBalancerName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("loadBalancerName", loadBalancerName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{loadBalancerName}", System.Uri.EscapeDataString(loadBalancerName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, LoadBalancer parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, loadBalancerName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/loadBalancers").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (loadBalancerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "loadBalancerName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("loadBalancerName", loadBalancerName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{loadBalancerName}", System.Uri.EscapeDataString(loadBalancerName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 202 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a load balancer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string loadBalancerName, LoadBalancer parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (loadBalancerName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "loadBalancerName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("loadBalancerName", loadBalancerName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{loadBalancerName}", System.Uri.EscapeDataString(loadBalancerName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/LoadBalancersOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/LoadBalancersOperationsExtensions.cs index a756b5738..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/LoadBalancersOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/LoadBalancersOperationsExtensions.cs @@ -1,363 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for LoadBalancersOperations. - /// - public static partial class LoadBalancersOperationsExtensions - { - /// - /// Deletes the specified load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - public static void Delete(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName) - { - operations.DeleteAsync(resourceGroupName, loadBalancerName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, loadBalancerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Expands referenced resources. - /// - public static LoadBalancer Get(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, loadBalancerName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, loadBalancerName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer operation. - /// - public static LoadBalancer CreateOrUpdate(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, LoadBalancer parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, loadBalancerName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, LoadBalancer parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, loadBalancerName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this ILoadBalancersOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this ILoadBalancersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this ILoadBalancersOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ILoadBalancersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - public static void BeginDelete(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName) - { - operations.BeginDeleteAsync(resourceGroupName, loadBalancerName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, loadBalancerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer operation. - /// - public static LoadBalancer BeginCreateOrUpdate(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, LoadBalancer parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, loadBalancerName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a load balancer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the load balancer. - /// - /// - /// Parameters supplied to the create or update load balancer operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this ILoadBalancersOperations operations, string resourceGroupName, string loadBalancerName, LoadBalancer parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, loadBalancerName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this ILoadBalancersOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the load balancers in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this ILoadBalancersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ILoadBalancersOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the load balancers in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this ILoadBalancersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperations.cs b/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperations.cs index e6497253a..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperations.cs +++ b/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperations.cs @@ -1,1058 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// LocalNetworkGatewaysOperations operations. - /// - internal partial class LocalNetworkGatewaysOperations : IServiceOperations, ILocalNetworkGatewaysOperations - { - /// - /// Initializes a new instance of the LocalNetworkGatewaysOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal LocalNetworkGatewaysOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Creates or updates a local network gateway in the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, localNetworkGatewayName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified local network gateway in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (localNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "localNetworkGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("localNetworkGatewayName", localNetworkGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{localNetworkGatewayName}", System.Uri.EscapeDataString(localNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified local network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, localNetworkGatewayName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a local network gateway in the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (localNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "localNetworkGatewayName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("localNetworkGatewayName", localNetworkGatewayName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{localNetworkGatewayName}", System.Uri.EscapeDataString(localNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified local network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string localNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (localNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "localNetworkGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("localNetworkGatewayName", localNetworkGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{localNetworkGatewayName}", System.Uri.EscapeDataString(localNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperationsExtensions.cs index afae1d289..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/LocalNetworkGatewaysOperationsExtensions.cs @@ -1,299 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for LocalNetworkGatewaysOperations. - /// - public static partial class LocalNetworkGatewaysOperationsExtensions - { - /// - /// Creates or updates a local network gateway in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - public static LocalNetworkGateway CreateOrUpdate(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, localNetworkGatewayName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a local network gateway in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, localNetworkGatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the specified local network gateway in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - public static LocalNetworkGateway Get(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName) - { - return operations.GetAsync(resourceGroupName, localNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified local network gateway in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, localNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified local network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - public static void Delete(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName) - { - operations.DeleteAsync(resourceGroupName, localNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified local network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, localNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this ILocalNetworkGatewaysOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a local network gateway in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - public static LocalNetworkGateway BeginCreateOrUpdate(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, localNetworkGatewayName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a local network gateway in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// Parameters supplied to the create or update local network gateway - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName, LocalNetworkGateway parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, localNetworkGatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified local network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - public static void BeginDelete(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName) - { - operations.BeginDeleteAsync(resourceGroupName, localNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified local network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the local network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this ILocalNetworkGatewaysOperations operations, string resourceGroupName, string localNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, localNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ILocalNetworkGatewaysOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the local network gateways in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this ILocalNetworkGatewaysOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Access.cs b/Samples/test/end-to-end/network/Client/Models/Access.cs index 26b95af1c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Access.cs +++ b/Samples/test/end-to-end/network/Client/Models/Access.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for Access. - /// - public static class Access - { - public const string Allow = "Allow"; - public const string Deny = "Deny"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/AddressSpace.cs b/Samples/test/end-to-end/network/Client/Models/AddressSpace.cs index f401d276a..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/AddressSpace.cs +++ b/Samples/test/end-to-end/network/Client/Models/AddressSpace.cs @@ -1,52 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// AddressSpace contains an array of IP address ranges that can be used by - /// subnets of the virtual network. - /// - public partial class AddressSpace - { - /// - /// Initializes a new instance of the AddressSpace class. - /// - public AddressSpace() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the AddressSpace class. - /// - /// A list of address blocks reserved for - /// this virtual network in CIDR notation. - public AddressSpace(IList addressPrefixes = default(IList)) - { - AddressPrefixes = addressPrefixes; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a list of address blocks reserved for this virtual - /// network in CIDR notation. - /// - [JsonProperty(PropertyName = "addressPrefixes")] - public IList AddressPrefixes { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGateway.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGateway.cs index 60f863bf9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGateway.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGateway.cs @@ -1,249 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Application gateway resource - /// - [JsonTransformation] - public partial class ApplicationGateway : Resource - { - /// - /// Initializes a new instance of the ApplicationGateway class. - /// - public ApplicationGateway() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGateway class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// SKU of the application gateway resource. - /// SSL policy of the application gateway - /// resource. - /// Operational state of the application - /// gateway resource. Possible values are: 'Stopped', 'Started', - /// 'Running', and 'Stopping'. Possible values include: 'Stopped', - /// 'Starting', 'Running', 'Stopping' - /// Subnets of application the - /// gateway resource. - /// Authentication - /// certificates of the application gateway resource. - /// SSL certificates of the application - /// gateway resource. - /// Frontend IP addresses of the - /// application gateway resource. - /// Frontend ports of the application - /// gateway resource. - /// Probes of the application gateway - /// resource. - /// Backend address pool of the - /// application gateway resource. - /// Backend http settings - /// of the application gateway resource. - /// Http listeners of the application - /// gateway resource. - /// URL path map of the application gateway - /// resource. - /// Request routing rules of the - /// application gateway resource. - /// Web application - /// firewall configuration. - /// Resource GUID property of the - /// application gateway resource. - /// Provisioning state of the - /// application gateway resource. Possible values are: 'Updating', - /// 'Deleting', and 'Failed'. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGateway(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ApplicationGatewaySku sku = default(ApplicationGatewaySku), ApplicationGatewaySslPolicy sslPolicy = default(ApplicationGatewaySslPolicy), string operationalState = default(string), IList gatewayIPConfigurations = default(IList), IList authenticationCertificates = default(IList), IList sslCertificates = default(IList), IList frontendIPConfigurations = default(IList), IList frontendPorts = default(IList), IList probes = default(IList), IList backendAddressPools = default(IList), IList backendHttpSettingsCollection = default(IList), IList httpListeners = default(IList), IList urlPathMaps = default(IList), IList requestRoutingRules = default(IList), ApplicationGatewayWebApplicationFirewallConfiguration webApplicationFirewallConfiguration = default(ApplicationGatewayWebApplicationFirewallConfiguration), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - Sku = sku; - SslPolicy = sslPolicy; - OperationalState = operationalState; - GatewayIPConfigurations = gatewayIPConfigurations; - AuthenticationCertificates = authenticationCertificates; - SslCertificates = sslCertificates; - FrontendIPConfigurations = frontendIPConfigurations; - FrontendPorts = frontendPorts; - Probes = probes; - BackendAddressPools = backendAddressPools; - BackendHttpSettingsCollection = backendHttpSettingsCollection; - HttpListeners = httpListeners; - UrlPathMaps = urlPathMaps; - RequestRoutingRules = requestRoutingRules; - WebApplicationFirewallConfiguration = webApplicationFirewallConfiguration; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets SKU of the application gateway resource. - /// - [JsonProperty(PropertyName = "properties.sku")] - public ApplicationGatewaySku Sku { get; set; } - - /// - /// Gets or sets SSL policy of the application gateway resource. - /// - [JsonProperty(PropertyName = "properties.sslPolicy")] - public ApplicationGatewaySslPolicy SslPolicy { get; set; } - - /// - /// Gets operational state of the application gateway resource. - /// Possible values are: 'Stopped', 'Started', 'Running', and - /// 'Stopping'. Possible values include: 'Stopped', 'Starting', - /// 'Running', 'Stopping' - /// - [JsonProperty(PropertyName = "properties.operationalState")] - public string OperationalState { get; private set; } - - /// - /// Gets or sets subnets of application the gateway resource. - /// - [JsonProperty(PropertyName = "properties.gatewayIPConfigurations")] - public IList GatewayIPConfigurations { get; set; } - - /// - /// Gets or sets authentication certificates of the application gateway - /// resource. - /// - [JsonProperty(PropertyName = "properties.authenticationCertificates")] - public IList AuthenticationCertificates { get; set; } - - /// - /// Gets or sets SSL certificates of the application gateway resource. - /// - [JsonProperty(PropertyName = "properties.sslCertificates")] - public IList SslCertificates { get; set; } - - /// - /// Gets or sets frontend IP addresses of the application gateway - /// resource. - /// - [JsonProperty(PropertyName = "properties.frontendIPConfigurations")] - public IList FrontendIPConfigurations { get; set; } - - /// - /// Gets or sets frontend ports of the application gateway resource. - /// - [JsonProperty(PropertyName = "properties.frontendPorts")] - public IList FrontendPorts { get; set; } - - /// - /// Gets or sets probes of the application gateway resource. - /// - [JsonProperty(PropertyName = "properties.probes")] - public IList Probes { get; set; } - - /// - /// Gets or sets backend address pool of the application gateway - /// resource. - /// - [JsonProperty(PropertyName = "properties.backendAddressPools")] - public IList BackendAddressPools { get; set; } - - /// - /// Gets or sets backend http settings of the application gateway - /// resource. - /// - [JsonProperty(PropertyName = "properties.backendHttpSettingsCollection")] - public IList BackendHttpSettingsCollection { get; set; } - - /// - /// Gets or sets http listeners of the application gateway resource. - /// - [JsonProperty(PropertyName = "properties.httpListeners")] - public IList HttpListeners { get; set; } - - /// - /// Gets or sets URL path map of the application gateway resource. - /// - [JsonProperty(PropertyName = "properties.urlPathMaps")] - public IList UrlPathMaps { get; set; } - - /// - /// Gets or sets request routing rules of the application gateway - /// resource. - /// - [JsonProperty(PropertyName = "properties.requestRoutingRules")] - public IList RequestRoutingRules { get; set; } - - /// - /// Gets or sets web application firewall configuration. - /// - [JsonProperty(PropertyName = "properties.webApplicationFirewallConfiguration")] - public ApplicationGatewayWebApplicationFirewallConfiguration WebApplicationFirewallConfiguration { get; set; } - - /// - /// Gets or sets resource GUID property of the application gateway - /// resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets or sets provisioning state of the application gateway - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (BackendHttpSettingsCollection != null) - { - foreach (var element in BackendHttpSettingsCollection) - { - if (element != null) - { - element.Validate(); - } - } - } - if (WebApplicationFirewallConfiguration != null) - { - WebApplicationFirewallConfiguration.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayAuthenticationCertificate.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayAuthenticationCertificate.cs index 9513daa4b..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayAuthenticationCertificate.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayAuthenticationCertificate.cs @@ -1,87 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Authentication certificates of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayAuthenticationCertificate : SubResource - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayAuthenticationCertificate class. - /// - public ApplicationGatewayAuthenticationCertificate() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayAuthenticationCertificate class. - /// - /// Resource ID. - /// Certificate public data. - /// Provisioning state of the - /// authentication certificate resource. Possible values are: - /// 'Updating', 'Deleting', and 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayAuthenticationCertificate(string id = default(string), string data = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Data = data; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets certificate public data. - /// - [JsonProperty(PropertyName = "properties.data")] - public string Data { get; set; } - - /// - /// Gets or sets provisioning state of the authentication certificate - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddress.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddress.cs index 1df1e3d3c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddress.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddress.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Backend address of an application gateway. - /// - public partial class ApplicationGatewayBackendAddress - { - /// - /// Initializes a new instance of the ApplicationGatewayBackendAddress - /// class. - /// - public ApplicationGatewayBackendAddress() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayBackendAddress - /// class. - /// - /// Fully qualified domain name (FQDN). - /// IP address - public ApplicationGatewayBackendAddress(string fqdn = default(string), string ipAddress = default(string)) - { - Fqdn = fqdn; - IpAddress = ipAddress; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets fully qualified domain name (FQDN). - /// - [JsonProperty(PropertyName = "fqdn")] - public string Fqdn { get; set; } - - /// - /// Gets or sets IP address - /// - [JsonProperty(PropertyName = "ipAddress")] - public string IpAddress { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddressPool.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddressPool.cs index 3f9e25884..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddressPool.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendAddressPool.cs @@ -1,98 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Backend Address Pool of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayBackendAddressPool : SubResource - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendAddressPool class. - /// - public ApplicationGatewayBackendAddressPool() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendAddressPool class. - /// - /// Resource ID. - /// Collection of references to - /// IPs defined in network interfaces. - /// Backend addresses - /// Provisioning state of the backend - /// address pool resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// Resource that is unique within a resource group. - /// This name can be used to access the resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayBackendAddressPool(string id = default(string), IList backendIPConfigurations = default(IList), IList backendAddresses = default(IList), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - BackendIPConfigurations = backendIPConfigurations; - BackendAddresses = backendAddresses; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets collection of references to IPs defined in network - /// interfaces. - /// - [JsonProperty(PropertyName = "properties.backendIPConfigurations")] - public IList BackendIPConfigurations { get; set; } - - /// - /// Gets or sets backend addresses - /// - [JsonProperty(PropertyName = "properties.backendAddresses")] - public IList BackendAddresses { get; set; } - - /// - /// Gets or sets provisioning state of the backend address pool - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets resource that is unique within a resource group. This - /// name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealth.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealth.cs index 810da22f3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealth.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealth.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// List of ApplicationGatewayBackendHealthPool resources. - /// - public partial class ApplicationGatewayBackendHealth - { - /// - /// Initializes a new instance of the ApplicationGatewayBackendHealth - /// class. - /// - public ApplicationGatewayBackendHealth() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayBackendHealth - /// class. - /// - public ApplicationGatewayBackendHealth(IList backendAddressPools = default(IList)) - { - BackendAddressPools = backendAddressPools; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "backendAddressPools")] - public IList BackendAddressPools { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthHttpSettings.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthHttpSettings.cs index 034c48204..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthHttpSettings.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthHttpSettings.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Application gateway BackendHealthHttp settings. - /// - public partial class ApplicationGatewayBackendHealthHttpSettings - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHealthHttpSettings class. - /// - public ApplicationGatewayBackendHealthHttpSettings() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHealthHttpSettings class. - /// - /// Reference of an - /// ApplicationGatewayBackendHttpSettings resource. - /// List of ApplicationGatewayBackendHealthServer - /// resources. - public ApplicationGatewayBackendHealthHttpSettings(ApplicationGatewayBackendHttpSettings backendHttpSettings = default(ApplicationGatewayBackendHttpSettings), IList servers = default(IList)) - { - BackendHttpSettings = backendHttpSettings; - Servers = servers; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets reference of an ApplicationGatewayBackendHttpSettings - /// resource. - /// - [JsonProperty(PropertyName = "backendHttpSettings")] - public ApplicationGatewayBackendHttpSettings BackendHttpSettings { get; set; } - - /// - /// Gets or sets list of ApplicationGatewayBackendHealthServer - /// resources. - /// - [JsonProperty(PropertyName = "servers")] - public IList Servers { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (BackendHttpSettings != null) - { - BackendHttpSettings.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthPool.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthPool.cs index 2c732e50d..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthPool.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthPool.cs @@ -1,63 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Application gateway BackendHealth pool. - /// - public partial class ApplicationGatewayBackendHealthPool - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHealthPool class. - /// - public ApplicationGatewayBackendHealthPool() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHealthPool class. - /// - /// Reference of an - /// ApplicationGatewayBackendAddressPool resource. - /// List of - /// ApplicationGatewayBackendHealthHttpSettings resources. - public ApplicationGatewayBackendHealthPool(ApplicationGatewayBackendAddressPool backendAddressPool = default(ApplicationGatewayBackendAddressPool), IList backendHttpSettingsCollection = default(IList)) - { - BackendAddressPool = backendAddressPool; - BackendHttpSettingsCollection = backendHttpSettingsCollection; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets reference of an ApplicationGatewayBackendAddressPool - /// resource. - /// - [JsonProperty(PropertyName = "backendAddressPool")] - public ApplicationGatewayBackendAddressPool BackendAddressPool { get; set; } - - /// - /// Gets or sets list of ApplicationGatewayBackendHealthHttpSettings - /// resources. - /// - [JsonProperty(PropertyName = "backendHttpSettingsCollection")] - public IList BackendHttpSettingsCollection { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServer.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServer.cs index ac1c83225..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServer.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServer.cs @@ -1,70 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Application gateway backendhealth http settings. - /// - public partial class ApplicationGatewayBackendHealthServer - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHealthServer class. - /// - public ApplicationGatewayBackendHealthServer() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHealthServer class. - /// - /// IP address or FQDN of backend server. - /// Reference of IP configuration of - /// backend server. - /// Health of backend server. Possible values are: - /// 'Unknown', 'Up', 'Down', and 'Partial'. Possible values include: - /// 'Unknown', 'Up', 'Down', 'Partial' - public ApplicationGatewayBackendHealthServer(string address = default(string), SubResource ipConfiguration = default(SubResource), string health = default(string)) - { - Address = address; - IpConfiguration = ipConfiguration; - Health = health; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets IP address or FQDN of backend server. - /// - [JsonProperty(PropertyName = "address")] - public string Address { get; set; } - - /// - /// Gets or sets reference of IP configuration of backend server. - /// - [JsonProperty(PropertyName = "ipConfiguration")] - public SubResource IpConfiguration { get; set; } - - /// - /// Gets or sets health of backend server. Possible values are: - /// 'Unknown', 'Up', 'Down', and 'Partial'. Possible values include: - /// 'Unknown', 'Up', 'Down', 'Partial' - /// - [JsonProperty(PropertyName = "health")] - public string Health { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServerHealth.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServerHealth.cs index 84ddf16fc..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServerHealth.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHealthServerHealth.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewayBackendHealthServerHealth. - /// - public static class ApplicationGatewayBackendHealthServerHealth - { - public const string Unknown = "Unknown"; - public const string Up = "Up"; - public const string Down = "Down"; - public const string Partial = "Partial"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHttpSettings.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHttpSettings.cs index 4fe4f6707..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHttpSettings.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayBackendHttpSettings.cs @@ -1,165 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Backend address pool settings of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayBackendHttpSettings : SubResource - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHttpSettings class. - /// - public ApplicationGatewayBackendHttpSettings() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayBackendHttpSettings class. - /// - /// Resource ID. - /// Port - /// Protocol. Possible values are: 'Http' and - /// 'Https'. Possible values include: 'Http', 'Https' - /// Cookie based affinity. Possible - /// values are: 'Enabled' and 'Disabled'. Possible values include: - /// 'Enabled', 'Disabled' - /// Request timeout in seconds. - /// Application Gateway will fail the request if response is not - /// received within RequestTimeout. Acceptable values are from 1 second - /// to 86400 seconds. - /// Probe resource of an application - /// gateway. - /// Array of references to - /// application gateway authentication certificates. - /// Provisioning state of the backend - /// http settings resource. Possible values are: 'Updating', - /// 'Deleting', and 'Failed'. - /// Connection draining of the backend - /// http settings resource. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayBackendHttpSettings(string id = default(string), int? port = default(int?), string protocol = default(string), string cookieBasedAffinity = default(string), int? requestTimeout = default(int?), SubResource probe = default(SubResource), IList authenticationCertificates = default(IList), string provisioningState = default(string), ApplicationGatewayConnectionDraining connectionDraining = default(ApplicationGatewayConnectionDraining), string name = default(string), string etag = default(string)) - : base(id) - { - Port = port; - Protocol = protocol; - CookieBasedAffinity = cookieBasedAffinity; - RequestTimeout = requestTimeout; - Probe = probe; - AuthenticationCertificates = authenticationCertificates; - ProvisioningState = provisioningState; - ConnectionDraining = connectionDraining; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets port - /// - [JsonProperty(PropertyName = "properties.port")] - public int? Port { get; set; } - - /// - /// Gets or sets protocol. Possible values are: 'Http' and 'Https'. - /// Possible values include: 'Http', 'Https' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets cookie based affinity. Possible values are: 'Enabled' - /// and 'Disabled'. Possible values include: 'Enabled', 'Disabled' - /// - [JsonProperty(PropertyName = "properties.cookieBasedAffinity")] - public string CookieBasedAffinity { get; set; } - - /// - /// Gets or sets request timeout in seconds. Application Gateway will - /// fail the request if response is not received within RequestTimeout. - /// Acceptable values are from 1 second to 86400 seconds. - /// - [JsonProperty(PropertyName = "properties.requestTimeout")] - public int? RequestTimeout { get; set; } - - /// - /// Gets or sets probe resource of an application gateway. - /// - [JsonProperty(PropertyName = "properties.probe")] - public SubResource Probe { get; set; } - - /// - /// Gets or sets array of references to application gateway - /// authentication certificates. - /// - [JsonProperty(PropertyName = "properties.authenticationCertificates")] - public IList AuthenticationCertificates { get; set; } - - /// - /// Gets or sets provisioning state of the backend http settings - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets connection draining of the backend http settings - /// resource. - /// - [JsonProperty(PropertyName = "properties.connectionDraining")] - public ApplicationGatewayConnectionDraining ConnectionDraining { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (ConnectionDraining != null) - { - ConnectionDraining.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayConnectionDraining.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayConnectionDraining.cs index fb7bff04e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayConnectionDraining.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayConnectionDraining.cs @@ -1,81 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Connection draining allows open connections to a backend server to be - /// active for a specified time after the backend server got removed from - /// the configuration. - /// - public partial class ApplicationGatewayConnectionDraining - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayConnectionDraining class. - /// - public ApplicationGatewayConnectionDraining() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayConnectionDraining class. - /// - /// Whether connection draining is enabled or - /// not. - /// The number of seconds connection - /// draining is active. Acceptable values are from 1 second to 3600 - /// seconds. - public ApplicationGatewayConnectionDraining(bool enabled, int drainTimeoutInSec) - { - Enabled = enabled; - DrainTimeoutInSec = drainTimeoutInSec; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets whether connection draining is enabled or not. - /// - [JsonProperty(PropertyName = "enabled")] - public bool Enabled { get; set; } - - /// - /// Gets or sets the number of seconds connection draining is active. - /// Acceptable values are from 1 second to 3600 seconds. - /// - [JsonProperty(PropertyName = "drainTimeoutInSec")] - public int DrainTimeoutInSec { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (DrainTimeoutInSec > 3600) - { - throw new ValidationException(ValidationRules.InclusiveMaximum, "DrainTimeoutInSec", 3600); - } - if (DrainTimeoutInSec < 1) - { - throw new ValidationException(ValidationRules.InclusiveMinimum, "DrainTimeoutInSec", 1); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayCookieBasedAffinity.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayCookieBasedAffinity.cs index 66eacb830..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayCookieBasedAffinity.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayCookieBasedAffinity.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewayCookieBasedAffinity. - /// - public static class ApplicationGatewayCookieBasedAffinity - { - public const string Enabled = "Enabled"; - public const string Disabled = "Disabled"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFirewallMode.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFirewallMode.cs index a102cd723..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFirewallMode.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFirewallMode.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewayFirewallMode. - /// - public static class ApplicationGatewayFirewallMode - { - public const string Detection = "Detection"; - public const string Prevention = "Prevention"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendIPConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendIPConfiguration.cs index e9a659dcf..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendIPConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendIPConfiguration.cs @@ -1,117 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Frontend IP configuration of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayFrontendIPConfiguration : SubResource - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayFrontendIPConfiguration class. - /// - public ApplicationGatewayFrontendIPConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayFrontendIPConfiguration class. - /// - /// Resource ID. - /// PrivateIPAddress of the network - /// interface IP Configuration. - /// PrivateIP allocation - /// method. Possible values are: 'Static' and 'Dynamic'. Possible - /// values include: 'Static', 'Dynamic' - /// Reference of the subnet resource. - /// Reference of the PublicIP - /// resource. - /// Provisioning state of the public IP - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayFrontendIPConfiguration(string id = default(string), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), SubResource subnet = default(SubResource), SubResource publicIPAddress = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - PrivateIPAddress = privateIPAddress; - PrivateIPAllocationMethod = privateIPAllocationMethod; - Subnet = subnet; - PublicIPAddress = publicIPAddress; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets privateIPAddress of the network interface IP - /// Configuration. - /// - [JsonProperty(PropertyName = "properties.privateIPAddress")] - public string PrivateIPAddress { get; set; } - - /// - /// Gets or sets privateIP allocation method. Possible values are: - /// 'Static' and 'Dynamic'. Possible values include: 'Static', - /// 'Dynamic' - /// - [JsonProperty(PropertyName = "properties.privateIPAllocationMethod")] - public string PrivateIPAllocationMethod { get; set; } - - /// - /// Gets or sets reference of the subnet resource. - /// - [JsonProperty(PropertyName = "properties.subnet")] - public SubResource Subnet { get; set; } - - /// - /// Gets or sets reference of the PublicIP resource. - /// - [JsonProperty(PropertyName = "properties.publicIPAddress")] - public SubResource PublicIPAddress { get; set; } - - /// - /// Gets or sets provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendPort.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendPort.cs index f7202f0da..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendPort.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayFrontendPort.cs @@ -1,86 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Frontend port of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayFrontendPort : SubResource - { - /// - /// Initializes a new instance of the ApplicationGatewayFrontendPort - /// class. - /// - public ApplicationGatewayFrontendPort() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayFrontendPort - /// class. - /// - /// Resource ID. - /// Frontend port - /// Provisioning state of the frontend - /// port resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayFrontendPort(string id = default(string), int? port = default(int?), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Port = port; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets frontend port - /// - [JsonProperty(PropertyName = "properties.port")] - public int? Port { get; set; } - - /// - /// Gets or sets provisioning state of the frontend port resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayHttpListener.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayHttpListener.cs index 11cd15d67..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayHttpListener.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayHttpListener.cs @@ -1,134 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Http listener of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayHttpListener : SubResource - { - /// - /// Initializes a new instance of the ApplicationGatewayHttpListener - /// class. - /// - public ApplicationGatewayHttpListener() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayHttpListener - /// class. - /// - /// Resource ID. - /// Frontend IP configuration - /// resource of an application gateway. - /// Frontend port resource of an application - /// gateway. - /// Protocol. Possible values are: 'Http' and - /// 'Https'. Possible values include: 'Http', 'Https' - /// Host name of HTTP listener. - /// SSL certificate resource of an - /// application gateway. - /// Applicable only if - /// protocol is https. Enables SNI for multi-hosting. - /// Provisioning state of the HTTP - /// listener resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayHttpListener(string id = default(string), SubResource frontendIPConfiguration = default(SubResource), SubResource frontendPort = default(SubResource), string protocol = default(string), string hostName = default(string), SubResource sslCertificate = default(SubResource), bool? requireServerNameIndication = default(bool?), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - FrontendIPConfiguration = frontendIPConfiguration; - FrontendPort = frontendPort; - Protocol = protocol; - HostName = hostName; - SslCertificate = sslCertificate; - RequireServerNameIndication = requireServerNameIndication; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets frontend IP configuration resource of an application - /// gateway. - /// - [JsonProperty(PropertyName = "properties.frontendIPConfiguration")] - public SubResource FrontendIPConfiguration { get; set; } - - /// - /// Gets or sets frontend port resource of an application gateway. - /// - [JsonProperty(PropertyName = "properties.frontendPort")] - public SubResource FrontendPort { get; set; } - - /// - /// Gets or sets protocol. Possible values are: 'Http' and 'Https'. - /// Possible values include: 'Http', 'Https' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets host name of HTTP listener. - /// - [JsonProperty(PropertyName = "properties.hostName")] - public string HostName { get; set; } - - /// - /// Gets or sets SSL certificate resource of an application gateway. - /// - [JsonProperty(PropertyName = "properties.sslCertificate")] - public SubResource SslCertificate { get; set; } - - /// - /// Gets or sets applicable only if protocol is https. Enables SNI for - /// multi-hosting. - /// - [JsonProperty(PropertyName = "properties.requireServerNameIndication")] - public bool? RequireServerNameIndication { get; set; } - - /// - /// Gets or sets provisioning state of the HTTP listener resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayIPConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayIPConfiguration.cs index af5591425..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayIPConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayIPConfiguration.cs @@ -1,90 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// IP configuration of an application gateway. Currently 1 public and 1 - /// private IP configuration is allowed. - /// - [JsonTransformation] - public partial class ApplicationGatewayIPConfiguration : SubResource - { - /// - /// Initializes a new instance of the ApplicationGatewayIPConfiguration - /// class. - /// - public ApplicationGatewayIPConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayIPConfiguration - /// class. - /// - /// Resource ID. - /// Reference of the subnet resource. A subnet - /// from where application gateway gets its private address. - /// Provisioning state of the - /// application gateway subnet resource. Possible values are: - /// 'Updating', 'Deleting', and 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayIPConfiguration(string id = default(string), SubResource subnet = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Subnet = subnet; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets reference of the subnet resource. A subnet from where - /// application gateway gets its private address. - /// - [JsonProperty(PropertyName = "properties.subnet")] - public SubResource Subnet { get; set; } - - /// - /// Gets or sets provisioning state of the application gateway subnet - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayOperationalState.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayOperationalState.cs index f0be65610..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayOperationalState.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayOperationalState.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewayOperationalState. - /// - public static class ApplicationGatewayOperationalState - { - public const string Stopped = "Stopped"; - public const string Starting = "Starting"; - public const string Running = "Running"; - public const string Stopping = "Stopping"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayPathRule.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayPathRule.cs index f77697cc5..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayPathRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayPathRule.cs @@ -1,103 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Path rule of URL path map of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayPathRule : SubResource - { - /// - /// Initializes a new instance of the ApplicationGatewayPathRule class. - /// - public ApplicationGatewayPathRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayPathRule class. - /// - /// Resource ID. - /// Path rules of URL path map. - /// Backend address pool resource of - /// URL path map. - /// Backend http settings resource of - /// URL path map. - /// Path rule of URL path map resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayPathRule(string id = default(string), IList paths = default(IList), SubResource backendAddressPool = default(SubResource), SubResource backendHttpSettings = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Paths = paths; - BackendAddressPool = backendAddressPool; - BackendHttpSettings = backendHttpSettings; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets path rules of URL path map. - /// - [JsonProperty(PropertyName = "properties.paths")] - public IList Paths { get; set; } - - /// - /// Gets or sets backend address pool resource of URL path map. - /// - [JsonProperty(PropertyName = "properties.backendAddressPool")] - public SubResource BackendAddressPool { get; set; } - - /// - /// Gets or sets backend http settings resource of URL path map. - /// - [JsonProperty(PropertyName = "properties.backendHttpSettings")] - public SubResource BackendHttpSettings { get; set; } - - /// - /// Gets or sets path rule of URL path map resource. Possible values - /// are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProbe.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProbe.cs index 13573a4e1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProbe.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProbe.cs @@ -1,144 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Probe of the application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayProbe : SubResource - { - /// - /// Initializes a new instance of the ApplicationGatewayProbe class. - /// - public ApplicationGatewayProbe() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayProbe class. - /// - /// Resource ID. - /// Protocol. Possible values are: 'Http' and - /// 'Https'. Possible values include: 'Http', 'Https' - /// Host name to send the probe to. - /// Relative path of probe. Valid path starts from - /// '/'. Probe is sent to - /// <Protocol>://<host>:<port><path> - /// The probing interval in seconds. This is the - /// time interval between two consecutive probes. Acceptable values are - /// from 1 second to 86400 seconds. - /// the probe timeout in seconds. Probe marked as - /// failed if valid response is not received with this timeout period. - /// Acceptable values are from 1 second to 86400 seconds. - /// The probe retry count. Backend - /// server is marked down after consecutive probe failure count reaches - /// UnhealthyThreshold. Acceptable values are from 1 second to - /// 20. - /// Provisioning state of the backend - /// http settings resource. Possible values are: 'Updating', - /// 'Deleting', and 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayProbe(string id = default(string), string protocol = default(string), string host = default(string), string path = default(string), int? interval = default(int?), int? timeout = default(int?), int? unhealthyThreshold = default(int?), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Protocol = protocol; - Host = host; - Path = path; - Interval = interval; - Timeout = timeout; - UnhealthyThreshold = unhealthyThreshold; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets protocol. Possible values are: 'Http' and 'Https'. - /// Possible values include: 'Http', 'Https' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets host name to send the probe to. - /// - [JsonProperty(PropertyName = "properties.host")] - public string Host { get; set; } - - /// - /// Gets or sets relative path of probe. Valid path starts from '/'. - /// Probe is sent to - /// &lt;Protocol&gt;://&lt;host&gt;:&lt;port&gt;&lt;path&gt; - /// - [JsonProperty(PropertyName = "properties.path")] - public string Path { get; set; } - - /// - /// Gets or sets the probing interval in seconds. This is the time - /// interval between two consecutive probes. Acceptable values are from - /// 1 second to 86400 seconds. - /// - [JsonProperty(PropertyName = "properties.interval")] - public int? Interval { get; set; } - - /// - /// Gets or sets the probe timeout in seconds. Probe marked as failed - /// if valid response is not received with this timeout period. - /// Acceptable values are from 1 second to 86400 seconds. - /// - [JsonProperty(PropertyName = "properties.timeout")] - public int? Timeout { get; set; } - - /// - /// Gets or sets the probe retry count. Backend server is marked down - /// after consecutive probe failure count reaches UnhealthyThreshold. - /// Acceptable values are from 1 second to 20. - /// - [JsonProperty(PropertyName = "properties.unhealthyThreshold")] - public int? UnhealthyThreshold { get; set; } - - /// - /// Gets or sets provisioning state of the backend http settings - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProtocol.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProtocol.cs index 26212b512..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProtocol.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayProtocol.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewayProtocol. - /// - public static class ApplicationGatewayProtocol - { - public const string Http = "Http"; - public const string Https = "Https"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRule.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRule.cs index 36eb6b286..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRule.cs @@ -1,128 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Request routing rule of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewayRequestRoutingRule : SubResource - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayRequestRoutingRule class. - /// - public ApplicationGatewayRequestRoutingRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayRequestRoutingRule class. - /// - /// Resource ID. - /// Rule type. Possible values are: 'Basic' and - /// 'PathBasedRouting'. Possible values include: 'Basic', - /// 'PathBasedRouting' - /// Backend address pool resource of - /// the application gateway. - /// Frontend port resource of the - /// application gateway. - /// Http listener resource of the - /// application gateway. - /// URL path map resource of the application - /// gateway. - /// Provisioning state of the request - /// routing rule resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayRequestRoutingRule(string id = default(string), string ruleType = default(string), SubResource backendAddressPool = default(SubResource), SubResource backendHttpSettings = default(SubResource), SubResource httpListener = default(SubResource), SubResource urlPathMap = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - RuleType = ruleType; - BackendAddressPool = backendAddressPool; - BackendHttpSettings = backendHttpSettings; - HttpListener = httpListener; - UrlPathMap = urlPathMap; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets rule type. Possible values are: 'Basic' and - /// 'PathBasedRouting'. Possible values include: 'Basic', - /// 'PathBasedRouting' - /// - [JsonProperty(PropertyName = "properties.ruleType")] - public string RuleType { get; set; } - - /// - /// Gets or sets backend address pool resource of the application - /// gateway. - /// - [JsonProperty(PropertyName = "properties.backendAddressPool")] - public SubResource BackendAddressPool { get; set; } - - /// - /// Gets or sets frontend port resource of the application gateway. - /// - [JsonProperty(PropertyName = "properties.backendHttpSettings")] - public SubResource BackendHttpSettings { get; set; } - - /// - /// Gets or sets http listener resource of the application gateway. - /// - [JsonProperty(PropertyName = "properties.httpListener")] - public SubResource HttpListener { get; set; } - - /// - /// Gets or sets URL path map resource of the application gateway. - /// - [JsonProperty(PropertyName = "properties.urlPathMap")] - public SubResource UrlPathMap { get; set; } - - /// - /// Gets or sets provisioning state of the request routing rule - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRuleType.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRuleType.cs index 2e934cb5b..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRuleType.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayRequestRoutingRuleType.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewayRequestRoutingRuleType. - /// - public static class ApplicationGatewayRequestRoutingRuleType - { - public const string Basic = "Basic"; - public const string PathBasedRouting = "PathBasedRouting"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySku.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySku.cs index 738e82e17..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySku.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySku.cs @@ -1,75 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// SKU of an application gateway - /// - public partial class ApplicationGatewaySku - { - /// - /// Initializes a new instance of the ApplicationGatewaySku class. - /// - public ApplicationGatewaySku() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewaySku class. - /// - /// Name of an application gateway SKU. Possible - /// values are: 'Standard_Small', 'Standard_Medium', 'Standard_Large', - /// 'WAF_Medium', and 'WAF_Large'. Possible values include: - /// 'Standard_Small', 'Standard_Medium', 'Standard_Large', - /// 'WAF_Medium', 'WAF_Large' - /// Tier of an application gateway. Possible values - /// are: 'Standard' and 'WAF'. Possible values include: 'Standard', - /// 'WAF' - /// Capacity (instance count) of an application - /// gateway. - public ApplicationGatewaySku(string name = default(string), string tier = default(string), int? capacity = default(int?)) - { - Name = name; - Tier = tier; - Capacity = capacity; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets name of an application gateway SKU. Possible values - /// are: 'Standard_Small', 'Standard_Medium', 'Standard_Large', - /// 'WAF_Medium', and 'WAF_Large'. Possible values include: - /// 'Standard_Small', 'Standard_Medium', 'Standard_Large', - /// 'WAF_Medium', 'WAF_Large' - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets tier of an application gateway. Possible values are: - /// 'Standard' and 'WAF'. Possible values include: 'Standard', 'WAF' - /// - [JsonProperty(PropertyName = "tier")] - public string Tier { get; set; } - - /// - /// Gets or sets capacity (instance count) of an application gateway. - /// - [JsonProperty(PropertyName = "capacity")] - public int? Capacity { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySkuName.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySkuName.cs index d72c05c1f..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySkuName.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySkuName.cs @@ -1,21 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewaySkuName. - /// - public static class ApplicationGatewaySkuName - { - public const string StandardSmall = "Standard_Small"; - public const string StandardMedium = "Standard_Medium"; - public const string StandardLarge = "Standard_Large"; - public const string WAFMedium = "WAF_Medium"; - public const string WAFLarge = "WAF_Large"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslCertificate.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslCertificate.cs index fdf4525f0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslCertificate.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslCertificate.cs @@ -1,109 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// SSL certificates of an application gateway. - /// - [JsonTransformation] - public partial class ApplicationGatewaySslCertificate : SubResource - { - /// - /// Initializes a new instance of the ApplicationGatewaySslCertificate - /// class. - /// - public ApplicationGatewaySslCertificate() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewaySslCertificate - /// class. - /// - /// Resource ID. - /// Base-64 encoded pfx certificate. Only applicable - /// in PUT Request. - /// Password for the pfx file specified in data. - /// Only applicable in PUT request. - /// Base-64 encoded Public cert data - /// corresponding to pfx specified in data. Only applicable in GET - /// request. - /// Provisioning state of the SSL - /// certificate resource Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewaySslCertificate(string id = default(string), string data = default(string), string password = default(string), string publicCertData = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Data = data; - Password = password; - PublicCertData = publicCertData; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets base-64 encoded pfx certificate. Only applicable in - /// PUT Request. - /// - [JsonProperty(PropertyName = "properties.data")] - public string Data { get; set; } - - /// - /// Gets or sets password for the pfx file specified in data. Only - /// applicable in PUT request. - /// - [JsonProperty(PropertyName = "properties.password")] - public string Password { get; set; } - - /// - /// Gets or sets base-64 encoded Public cert data corresponding to pfx - /// specified in data. Only applicable in GET request. - /// - [JsonProperty(PropertyName = "properties.publicCertData")] - public string PublicCertData { get; set; } - - /// - /// Gets or sets provisioning state of the SSL certificate resource - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslPolicy.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslPolicy.cs index fb1dcc0d0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslPolicy.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslPolicy.cs @@ -1,54 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Application gateway SSL policy. - /// - public partial class ApplicationGatewaySslPolicy - { - /// - /// Initializes a new instance of the ApplicationGatewaySslPolicy - /// class. - /// - public ApplicationGatewaySslPolicy() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewaySslPolicy - /// class. - /// - /// SSL protocols to be disabled on - /// application gateway. Possible values are: 'TLSv1_0', 'TLSv1_1', and - /// 'TLSv1_2'. - public ApplicationGatewaySslPolicy(IList disabledSslProtocols = default(IList)) - { - DisabledSslProtocols = disabledSslProtocols; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets SSL protocols to be disabled on application gateway. - /// Possible values are: 'TLSv1_0', 'TLSv1_1', and 'TLSv1_2'. - /// - [JsonProperty(PropertyName = "disabledSslProtocols")] - public IList DisabledSslProtocols { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslProtocol.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslProtocol.cs index 6573e3119..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslProtocol.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewaySslProtocol.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewaySslProtocol. - /// - public static class ApplicationGatewaySslProtocol - { - public const string TLSv10 = "TLSv1_0"; - public const string TLSv11 = "TLSv1_1"; - public const string TLSv12 = "TLSv1_2"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayTier.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayTier.cs index 01731a8d4..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayTier.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayTier.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ApplicationGatewayTier. - /// - public static class ApplicationGatewayTier - { - public const string Standard = "Standard"; - public const string WAF = "WAF"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayUrlPathMap.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayUrlPathMap.cs index f669f4260..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayUrlPathMap.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayUrlPathMap.cs @@ -1,109 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// UrlPathMaps give a url path to the backend mapping information for - /// PathBasedRouting. - /// - [JsonTransformation] - public partial class ApplicationGatewayUrlPathMap : SubResource - { - /// - /// Initializes a new instance of the ApplicationGatewayUrlPathMap - /// class. - /// - public ApplicationGatewayUrlPathMap() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ApplicationGatewayUrlPathMap - /// class. - /// - /// Resource ID. - /// Default backend address - /// pool resource of URL path map. - /// Default backend http - /// settings resource of URL path map. - /// Path rule of URL path map resource. - /// Provisioning state of the backend - /// http settings resource. Possible values are: 'Updating', - /// 'Deleting', and 'Failed'. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ApplicationGatewayUrlPathMap(string id = default(string), SubResource defaultBackendAddressPool = default(SubResource), SubResource defaultBackendHttpSettings = default(SubResource), IList pathRules = default(IList), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - DefaultBackendAddressPool = defaultBackendAddressPool; - DefaultBackendHttpSettings = defaultBackendHttpSettings; - PathRules = pathRules; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets default backend address pool resource of URL path map. - /// - [JsonProperty(PropertyName = "properties.defaultBackendAddressPool")] - public SubResource DefaultBackendAddressPool { get; set; } - - /// - /// Gets or sets default backend http settings resource of URL path - /// map. - /// - [JsonProperty(PropertyName = "properties.defaultBackendHttpSettings")] - public SubResource DefaultBackendHttpSettings { get; set; } - - /// - /// Gets or sets path rule of URL path map resource. - /// - [JsonProperty(PropertyName = "properties.pathRules")] - public IList PathRules { get; set; } - - /// - /// Gets or sets provisioning state of the backend http settings - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayWebApplicationFirewallConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayWebApplicationFirewallConfiguration.cs index e8e39aa87..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayWebApplicationFirewallConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/ApplicationGatewayWebApplicationFirewallConfiguration.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Application gateway web application firewall configuration. - /// - public partial class ApplicationGatewayWebApplicationFirewallConfiguration - { - /// - /// Initializes a new instance of the - /// ApplicationGatewayWebApplicationFirewallConfiguration class. - /// - public ApplicationGatewayWebApplicationFirewallConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ApplicationGatewayWebApplicationFirewallConfiguration class. - /// - /// Whether the web application firewall is - /// enabled or not. - /// Web application firewall mode. Possible - /// values are: 'Detection' and 'Prevention'. Possible values include: - /// 'Detection', 'Prevention' - public ApplicationGatewayWebApplicationFirewallConfiguration(bool enabled, string firewallMode = default(string)) - { - Enabled = enabled; - FirewallMode = firewallMode; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets whether the web application firewall is enabled or - /// not. - /// - [JsonProperty(PropertyName = "enabled")] - public bool Enabled { get; set; } - - /// - /// Gets or sets web application firewall mode. Possible values are: - /// 'Detection' and 'Prevention'. Possible values include: 'Detection', - /// 'Prevention' - /// - [JsonProperty(PropertyName = "firewallMode")] - public string FirewallMode { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/AssociationType.cs b/Samples/test/end-to-end/network/Client/Models/AssociationType.cs index 837c23ae7..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/AssociationType.cs +++ b/Samples/test/end-to-end/network/Client/Models/AssociationType.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for AssociationType. - /// - public static class AssociationType - { - public const string Associated = "Associated"; - public const string Contains = "Contains"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/AuthorizationUseStatus.cs b/Samples/test/end-to-end/network/Client/Models/AuthorizationUseStatus.cs index a449eb7e5..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/AuthorizationUseStatus.cs +++ b/Samples/test/end-to-end/network/Client/Models/AuthorizationUseStatus.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for AuthorizationUseStatus. - /// - public static class AuthorizationUseStatus - { - public const string Available = "Available"; - public const string InUse = "InUse"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/AzureAsyncOperationResult.cs b/Samples/test/end-to-end/network/Client/Models/AzureAsyncOperationResult.cs index 8ef658167..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/AzureAsyncOperationResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/AzureAsyncOperationResult.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The response body contains the status of the specified asynchronous - /// operation, indicating whether it has succeeded, is in progress, or has - /// failed. Note that this status is distinct from the HTTP status code - /// returned for the Get Operation Status operation itself. If the - /// asynchronous operation succeeded, the response body includes the HTTP - /// status code for the successful request. If the asynchronous operation - /// failed, the response body includes the HTTP status code for the failed - /// request and error information regarding the failure. - /// - public partial class AzureAsyncOperationResult - { - /// - /// Initializes a new instance of the AzureAsyncOperationResult class. - /// - public AzureAsyncOperationResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the AzureAsyncOperationResult class. - /// - /// Status of the Azure async operation. Possible - /// values are: 'InProgress', 'Succeeded', and 'Failed'. Possible - /// values include: 'InProgress', 'Succeeded', 'Failed' - public AzureAsyncOperationResult(string status = default(string), Error error = default(Error)) - { - Status = status; - Error = error; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets status of the Azure async operation. Possible values - /// are: 'InProgress', 'Succeeded', and 'Failed'. Possible values - /// include: 'InProgress', 'Succeeded', 'Failed' - /// - [JsonProperty(PropertyName = "status")] - public string Status { get; set; } - - /// - /// - [JsonProperty(PropertyName = "error")] - public Error Error { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/BGPCommunity.cs b/Samples/test/end-to-end/network/Client/Models/BGPCommunity.cs index 2684f28e9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/BGPCommunity.cs +++ b/Samples/test/end-to-end/network/Client/Models/BGPCommunity.cs @@ -1,81 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Contains bgp community information offered in Service Community - /// resources. - /// - public partial class BGPCommunity - { - /// - /// Initializes a new instance of the BGPCommunity class. - /// - public BGPCommunity() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BGPCommunity class. - /// - /// The region which the service - /// support. e.g. For O365, region is Global. - /// The name of the bgp community. e.g. - /// Skype. - /// The value of the bgp community. For - /// more information: - /// https://docs.microsoft.com/en-us/azure/expressroute/expressroute-routing. - /// The prefixes that the bgp community - /// contains. - public BGPCommunity(string serviceSupportedRegion = default(string), string communityName = default(string), string communityValue = default(string), IList communityPrefixes = default(IList)) - { - ServiceSupportedRegion = serviceSupportedRegion; - CommunityName = communityName; - CommunityValue = communityValue; - CommunityPrefixes = communityPrefixes; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the region which the service support. e.g. For O365, - /// region is Global. - /// - [JsonProperty(PropertyName = "serviceSupportedRegion")] - public string ServiceSupportedRegion { get; set; } - - /// - /// Gets or sets the name of the bgp community. e.g. Skype. - /// - [JsonProperty(PropertyName = "communityName")] - public string CommunityName { get; set; } - - /// - /// Gets or sets the value of the bgp community. For more information: - /// https://docs.microsoft.com/en-us/azure/expressroute/expressroute-routing. - /// - [JsonProperty(PropertyName = "communityValue")] - public string CommunityValue { get; set; } - - /// - /// Gets or sets the prefixes that the bgp community contains. - /// - [JsonProperty(PropertyName = "communityPrefixes")] - public IList CommunityPrefixes { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/BackendAddressPool.cs b/Samples/test/end-to-end/network/Client/Models/BackendAddressPool.cs index f83316230..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/BackendAddressPool.cs +++ b/Samples/test/end-to-end/network/Client/Models/BackendAddressPool.cs @@ -1,106 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Pool of backend IP addresses. - /// - [JsonTransformation] - public partial class BackendAddressPool : SubResource - { - /// - /// Initializes a new instance of the BackendAddressPool class. - /// - public BackendAddressPool() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BackendAddressPool class. - /// - /// Resource ID. - /// Gets collection of references - /// to IP addresses defined in network interfaces. - /// Gets load balancing rules that use - /// this backend address pool. - /// Gets outbound rules that use this - /// backend address pool. - /// Get provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// Gets name of the resource that is unique within - /// a resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public BackendAddressPool(string id = default(string), IList backendIPConfigurations = default(IList), IList loadBalancingRules = default(IList), SubResource outboundNatRule = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - BackendIPConfigurations = backendIPConfigurations; - LoadBalancingRules = loadBalancingRules; - OutboundNatRule = outboundNatRule; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets collection of references to IP addresses defined in network - /// interfaces. - /// - [JsonProperty(PropertyName = "properties.backendIPConfigurations")] - public IList BackendIPConfigurations { get; private set; } - - /// - /// Gets load balancing rules that use this backend address pool. - /// - [JsonProperty(PropertyName = "properties.loadBalancingRules")] - public IList LoadBalancingRules { get; private set; } - - /// - /// Gets outbound rules that use this backend address pool. - /// - [JsonProperty(PropertyName = "properties.outboundNatRule")] - public SubResource OutboundNatRule { get; private set; } - - /// - /// Gets or sets get provisioning state of the public IP resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets name of the resource that is unique within a resource group. - /// This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/BgpPeerState.cs b/Samples/test/end-to-end/network/Client/Models/BgpPeerState.cs index 1bf50c379..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/BgpPeerState.cs +++ b/Samples/test/end-to-end/network/Client/Models/BgpPeerState.cs @@ -1,21 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for BgpPeerState. - /// - public static class BgpPeerState - { - public const string Unknown = "Unknown"; - public const string Stopped = "Stopped"; - public const string Idle = "Idle"; - public const string Connecting = "Connecting"; - public const string Connected = "Connected"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/BgpPeerStatus.cs b/Samples/test/end-to-end/network/Client/Models/BgpPeerStatus.cs index ee6854f56..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/BgpPeerStatus.cs +++ b/Samples/test/end-to-end/network/Client/Models/BgpPeerStatus.cs @@ -1,107 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class BgpPeerStatus - { - /// - /// Initializes a new instance of the BgpPeerStatus class. - /// - public BgpPeerStatus() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BgpPeerStatus class. - /// - /// The virtual network gateway's local - /// address - /// The remote BGP peer - /// The autonomous system number of the remote BGP - /// peer - /// The BGP peer state. Possible values include: - /// 'Unknown', 'Stopped', 'Idle', 'Connecting', 'Connected' - /// For how long the peering has been - /// up - /// The number of routes learned from this - /// peer - /// The number of BGP messages sent - /// The number of BGP messages - /// received - public BgpPeerStatus(string localAddress = default(string), string neighbor = default(string), int? asn = default(int?), string state = default(string), string connectedDuration = default(string), long? routesReceived = default(long?), long? messagesSent = default(long?), int? messagesReceived = default(int?)) - { - LocalAddress = localAddress; - Neighbor = neighbor; - Asn = asn; - State = state; - ConnectedDuration = connectedDuration; - RoutesReceived = routesReceived; - MessagesSent = messagesSent; - MessagesReceived = messagesReceived; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the virtual network gateway's local address - /// - [JsonProperty(PropertyName = "localAddress")] - public string LocalAddress { get; private set; } - - /// - /// Gets the remote BGP peer - /// - [JsonProperty(PropertyName = "neighbor")] - public string Neighbor { get; private set; } - - /// - /// Gets the autonomous system number of the remote BGP peer - /// - [JsonProperty(PropertyName = "asn")] - public int? Asn { get; private set; } - - /// - /// Gets the BGP peer state. Possible values include: 'Unknown', - /// 'Stopped', 'Idle', 'Connecting', 'Connected' - /// - [JsonProperty(PropertyName = "state")] - public string State { get; private set; } - - /// - /// Gets for how long the peering has been up - /// - [JsonProperty(PropertyName = "connectedDuration")] - public string ConnectedDuration { get; private set; } - - /// - /// Gets the number of routes learned from this peer - /// - [JsonProperty(PropertyName = "routesReceived")] - public long? RoutesReceived { get; private set; } - - /// - /// Gets the number of BGP messages sent - /// - [JsonProperty(PropertyName = "messagesSent")] - public long? MessagesSent { get; private set; } - - /// - /// Gets the number of BGP messages received - /// - [JsonProperty(PropertyName = "messagesReceived")] - public int? MessagesReceived { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/BgpPeerStatusListResult.cs b/Samples/test/end-to-end/network/Client/Models/BgpPeerStatusListResult.cs index ebd9de4f9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/BgpPeerStatusListResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/BgpPeerStatusListResult.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response for list BGP peer status API service call - /// - public partial class BgpPeerStatusListResult - { - /// - /// Initializes a new instance of the BgpPeerStatusListResult class. - /// - public BgpPeerStatusListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BgpPeerStatusListResult class. - /// - /// List of BGP peers - public BgpPeerStatusListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets list of BGP peers - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/BgpServiceCommunity.cs b/Samples/test/end-to-end/network/Client/Models/BgpServiceCommunity.cs index 6507cf4a5..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/BgpServiceCommunity.cs +++ b/Samples/test/end-to-end/network/Client/Models/BgpServiceCommunity.cs @@ -1,67 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Service Community Properties. - /// - [JsonTransformation] - public partial class BgpServiceCommunity : Resource - { - /// - /// Initializes a new instance of the BgpServiceCommunity class. - /// - public BgpServiceCommunity() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BgpServiceCommunity class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// The name of the bgp community. e.g. - /// Skype. - /// Get a list of bgp communities. - public BgpServiceCommunity(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string serviceName = default(string), IList bgpCommunities = default(IList)) - : base(id, name, type, location, tags) - { - ServiceName = serviceName; - BgpCommunities = bgpCommunities; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the bgp community. e.g. Skype. - /// - [JsonProperty(PropertyName = "properties.serviceName")] - public string ServiceName { get; set; } - - /// - /// Gets or sets get a list of bgp communities. - /// - [JsonProperty(PropertyName = "properties.bgpCommunities")] - public IList BgpCommunities { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/BgpSettings.cs b/Samples/test/end-to-end/network/Client/Models/BgpSettings.cs index 47406767a..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/BgpSettings.cs +++ b/Samples/test/end-to-end/network/Client/Models/BgpSettings.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class BgpSettings - { - /// - /// Initializes a new instance of the BgpSettings class. - /// - public BgpSettings() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BgpSettings class. - /// - /// The BGP speaker's ASN. - /// The BGP peering address and BGP - /// identifier of this BGP speaker. - /// The weight added to routes learned from - /// this BGP speaker. - public BgpSettings(long? asn = default(long?), string bgpPeeringAddress = default(string), int? peerWeight = default(int?)) - { - Asn = asn; - BgpPeeringAddress = bgpPeeringAddress; - PeerWeight = peerWeight; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the BGP speaker's ASN. - /// - [JsonProperty(PropertyName = "asn")] - public long? Asn { get; set; } - - /// - /// Gets or sets the BGP peering address and BGP identifier of this BGP - /// speaker. - /// - [JsonProperty(PropertyName = "bgpPeeringAddress")] - public string BgpPeeringAddress { get; set; } - - /// - /// Gets or sets the weight added to routes learned from this BGP - /// speaker. - /// - [JsonProperty(PropertyName = "peerWeight")] - public int? PeerWeight { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ConnectionResetSharedKey.cs b/Samples/test/end-to-end/network/Client/Models/ConnectionResetSharedKey.cs index b596ab9ab..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ConnectionResetSharedKey.cs +++ b/Samples/test/end-to-end/network/Client/Models/ConnectionResetSharedKey.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - public partial class ConnectionResetSharedKey - { - /// - /// Initializes a new instance of the ConnectionResetSharedKey class. - /// - public ConnectionResetSharedKey() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ConnectionResetSharedKey class. - /// - /// The virtual network connection reset shared - /// key length, should between 1 and 128. - public ConnectionResetSharedKey(int keyLength) - { - KeyLength = keyLength; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the virtual network connection reset shared key - /// length, should between 1 and 128. - /// - [JsonProperty(PropertyName = "keyLength")] - public int KeyLength { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyLength > 128) - { - throw new ValidationException(ValidationRules.InclusiveMaximum, "KeyLength", 128); - } - if (KeyLength < 1) - { - throw new ValidationException(ValidationRules.InclusiveMinimum, "KeyLength", 1); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ConnectionSharedKey.cs b/Samples/test/end-to-end/network/Client/Models/ConnectionSharedKey.cs index 5e8374bdc..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ConnectionSharedKey.cs +++ b/Samples/test/end-to-end/network/Client/Models/ConnectionSharedKey.cs @@ -1,62 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Response for GetConnectionSharedKey API service call - /// - public partial class ConnectionSharedKey - { - /// - /// Initializes a new instance of the ConnectionSharedKey class. - /// - public ConnectionSharedKey() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ConnectionSharedKey class. - /// - /// The virtual network connection shared key - /// value. - public ConnectionSharedKey(string value) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the virtual network connection shared key value. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Value == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Value"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/DhcpOptions.cs b/Samples/test/end-to-end/network/Client/Models/DhcpOptions.cs index 1b3a3e48a..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/DhcpOptions.cs +++ b/Samples/test/end-to-end/network/Client/Models/DhcpOptions.cs @@ -1,52 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// DhcpOptions contains an array of DNS servers available to VMs deployed - /// in the virtual network. Standard DHCP option for a subnet overrides - /// VNET DHCP options. - /// - public partial class DhcpOptions - { - /// - /// Initializes a new instance of the DhcpOptions class. - /// - public DhcpOptions() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the DhcpOptions class. - /// - /// The list of DNS servers IP - /// addresses. - public DhcpOptions(IList dnsServers = default(IList)) - { - DnsServers = dnsServers; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the list of DNS servers IP addresses. - /// - [JsonProperty(PropertyName = "dnsServers")] - public IList DnsServers { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Direction.cs b/Samples/test/end-to-end/network/Client/Models/Direction.cs index 8f8b821ae..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Direction.cs +++ b/Samples/test/end-to-end/network/Client/Models/Direction.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for Direction. - /// - public static class Direction - { - public const string Inbound = "Inbound"; - public const string Outbound = "Outbound"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/DnsNameAvailabilityResult.cs b/Samples/test/end-to-end/network/Client/Models/DnsNameAvailabilityResult.cs index 6200eebd8..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/DnsNameAvailabilityResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/DnsNameAvailabilityResult.cs @@ -1,47 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Response for the CheckDnsNameAvailability API service call. - /// - public partial class DnsNameAvailabilityResult - { - /// - /// Initializes a new instance of the DnsNameAvailabilityResult class. - /// - public DnsNameAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the DnsNameAvailabilityResult class. - /// - /// Domain availability (True/False). - public DnsNameAvailabilityResult(bool? available = default(bool?)) - { - Available = available; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets domain availability (True/False). - /// - [JsonProperty(PropertyName = "available")] - public bool? Available { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroup.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroup.cs index 524d4cd1d..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroup.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroup.cs @@ -1,67 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Effective network security group. - /// - public partial class EffectiveNetworkSecurityGroup - { - /// - /// Initializes a new instance of the EffectiveNetworkSecurityGroup - /// class. - /// - public EffectiveNetworkSecurityGroup() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EffectiveNetworkSecurityGroup - /// class. - /// - /// The ID of network security group - /// that is applied. - /// A collection of effective - /// security rules. - public EffectiveNetworkSecurityGroup(SubResource networkSecurityGroup = default(SubResource), EffectiveNetworkSecurityGroupAssociation association = default(EffectiveNetworkSecurityGroupAssociation), IList effectiveSecurityRules = default(IList)) - { - NetworkSecurityGroup = networkSecurityGroup; - Association = association; - EffectiveSecurityRules = effectiveSecurityRules; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the ID of network security group that is applied. - /// - [JsonProperty(PropertyName = "networkSecurityGroup")] - public SubResource NetworkSecurityGroup { get; set; } - - /// - /// - [JsonProperty(PropertyName = "association")] - public EffectiveNetworkSecurityGroupAssociation Association { get; set; } - - /// - /// Gets or sets a collection of effective security rules. - /// - [JsonProperty(PropertyName = "effectiveSecurityRules")] - public IList EffectiveSecurityRules { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupAssociation.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupAssociation.cs index d52b065e4..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupAssociation.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupAssociation.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The effective network security group association. - /// - public partial class EffectiveNetworkSecurityGroupAssociation - { - /// - /// Initializes a new instance of the - /// EffectiveNetworkSecurityGroupAssociation class. - /// - public EffectiveNetworkSecurityGroupAssociation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// EffectiveNetworkSecurityGroupAssociation class. - /// - /// The ID of the subnet if assigned. - /// The ID of the network interface if - /// assigned. - public EffectiveNetworkSecurityGroupAssociation(SubResource subnet = default(SubResource), SubResource networkInterface = default(SubResource)) - { - Subnet = subnet; - NetworkInterface = networkInterface; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the ID of the subnet if assigned. - /// - [JsonProperty(PropertyName = "subnet")] - public SubResource Subnet { get; set; } - - /// - /// Gets or sets the ID of the network interface if assigned. - /// - [JsonProperty(PropertyName = "networkInterface")] - public SubResource NetworkInterface { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupListResult.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupListResult.cs index 7f85a44ab..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupListResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityGroupListResult.cs @@ -1,61 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response for list effective network security groups API service call. - /// - public partial class EffectiveNetworkSecurityGroupListResult - { - /// - /// Initializes a new instance of the - /// EffectiveNetworkSecurityGroupListResult class. - /// - public EffectiveNetworkSecurityGroupListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// EffectiveNetworkSecurityGroupListResult class. - /// - /// A list of effective network security - /// groups. - /// The URL to get the next set of - /// results. - public EffectiveNetworkSecurityGroupListResult(IList value = default(IList), string nextLink = default(string)) - { - Value = value; - NextLink = nextLink; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a list of effective network security groups. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - /// - /// Gets or sets the URL to get the next set of results. - /// - [JsonProperty(PropertyName = "nextLink")] - public string NextLink { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityRule.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityRule.cs index cce6928f1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveNetworkSecurityRule.cs @@ -1,150 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Effective network security rules. - /// - public partial class EffectiveNetworkSecurityRule - { - /// - /// Initializes a new instance of the EffectiveNetworkSecurityRule - /// class. - /// - public EffectiveNetworkSecurityRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EffectiveNetworkSecurityRule - /// class. - /// - /// The name of the security rule specified by the - /// user (if created by the user). - /// The network protocol this rule applies to. - /// Possible values are: 'Tcp', 'Udp', and '*'. Possible values - /// include: 'Tcp', 'Udp', '*' - /// The source port or range. - /// The destination port or - /// range. - /// The source address - /// prefix. - /// The destination address - /// prefix. - /// The expanded source - /// address prefix. - /// Expanded destination - /// address prefix. - /// Whether network traffic is allowed or denied. - /// Possible values are: 'Allow' and 'Deny'. Possible values include: - /// 'Allow', 'Deny' - /// The priority of the rule. - /// The direction of the rule. Possible values - /// are: 'Inbound and Outbound'. Possible values include: 'Inbound', - /// 'Outbound' - public EffectiveNetworkSecurityRule(string name = default(string), string protocol = default(string), string sourcePortRange = default(string), string destinationPortRange = default(string), string sourceAddressPrefix = default(string), string destinationAddressPrefix = default(string), IList expandedSourceAddressPrefix = default(IList), IList expandedDestinationAddressPrefix = default(IList), string access = default(string), int? priority = default(int?), string direction = default(string)) - { - Name = name; - Protocol = protocol; - SourcePortRange = sourcePortRange; - DestinationPortRange = destinationPortRange; - SourceAddressPrefix = sourceAddressPrefix; - DestinationAddressPrefix = destinationAddressPrefix; - ExpandedSourceAddressPrefix = expandedSourceAddressPrefix; - ExpandedDestinationAddressPrefix = expandedDestinationAddressPrefix; - Access = access; - Priority = priority; - Direction = direction; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the security rule specified by the user - /// (if created by the user). - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the network protocol this rule applies to. Possible - /// values are: 'Tcp', 'Udp', and '*'. Possible values include: 'Tcp', - /// 'Udp', '*' - /// - [JsonProperty(PropertyName = "protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets the source port or range. - /// - [JsonProperty(PropertyName = "sourcePortRange")] - public string SourcePortRange { get; set; } - - /// - /// Gets or sets the destination port or range. - /// - [JsonProperty(PropertyName = "destinationPortRange")] - public string DestinationPortRange { get; set; } - - /// - /// Gets or sets the source address prefix. - /// - [JsonProperty(PropertyName = "sourceAddressPrefix")] - public string SourceAddressPrefix { get; set; } - - /// - /// Gets or sets the destination address prefix. - /// - [JsonProperty(PropertyName = "destinationAddressPrefix")] - public string DestinationAddressPrefix { get; set; } - - /// - /// Gets or sets the expanded source address prefix. - /// - [JsonProperty(PropertyName = "expandedSourceAddressPrefix")] - public IList ExpandedSourceAddressPrefix { get; set; } - - /// - /// Gets or sets expanded destination address prefix. - /// - [JsonProperty(PropertyName = "expandedDestinationAddressPrefix")] - public IList ExpandedDestinationAddressPrefix { get; set; } - - /// - /// Gets or sets whether network traffic is allowed or denied. Possible - /// values are: 'Allow' and 'Deny'. Possible values include: 'Allow', - /// 'Deny' - /// - [JsonProperty(PropertyName = "access")] - public string Access { get; set; } - - /// - /// Gets or sets the priority of the rule. - /// - [JsonProperty(PropertyName = "priority")] - public int? Priority { get; set; } - - /// - /// Gets or sets the direction of the rule. Possible values are: - /// 'Inbound and Outbound'. Possible values include: 'Inbound', - /// 'Outbound' - /// - [JsonProperty(PropertyName = "direction")] - public string Direction { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveRoute.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveRoute.cs index 2346f6683..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveRoute.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveRoute.cs @@ -1,110 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Effective Route - /// - public partial class EffectiveRoute - { - /// - /// Initializes a new instance of the EffectiveRoute class. - /// - public EffectiveRoute() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EffectiveRoute class. - /// - /// The name of the user defined route. This is - /// optional. - /// Who created the route. Possible values are: - /// 'Unknown', 'User', 'VirtualNetworkGateway', and 'Default'. Possible - /// values include: 'Unknown', 'User', 'VirtualNetworkGateway', - /// 'Default' - /// The value of effective route. Possible values - /// are: 'Active' and 'Invalid'. Possible values include: 'Active', - /// 'Invalid' - /// The address prefixes of the effective - /// routes in CIDR notation. - /// The IP address of the next hop of - /// the effective route. - /// The type of Azure hop the packet should - /// be sent to. Possible values are: 'VirtualNetworkGateway', - /// 'VnetLocal', 'Internet', 'VirtualAppliance', and 'None'. Possible - /// values include: 'VirtualNetworkGateway', 'VnetLocal', 'Internet', - /// 'VirtualAppliance', 'None' - public EffectiveRoute(string name = default(string), string source = default(string), string state = default(string), IList addressPrefix = default(IList), IList nextHopIpAddress = default(IList), string nextHopType = default(string)) - { - Name = name; - Source = source; - State = state; - AddressPrefix = addressPrefix; - NextHopIpAddress = nextHopIpAddress; - NextHopType = nextHopType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the user defined route. This is optional. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets who created the route. Possible values are: 'Unknown', - /// 'User', 'VirtualNetworkGateway', and 'Default'. Possible values - /// include: 'Unknown', 'User', 'VirtualNetworkGateway', 'Default' - /// - [JsonProperty(PropertyName = "source")] - public string Source { get; set; } - - /// - /// Gets or sets the value of effective route. Possible values are: - /// 'Active' and 'Invalid'. Possible values include: 'Active', - /// 'Invalid' - /// - [JsonProperty(PropertyName = "state")] - public string State { get; set; } - - /// - /// Gets or sets the address prefixes of the effective routes in CIDR - /// notation. - /// - [JsonProperty(PropertyName = "addressPrefix")] - public IList AddressPrefix { get; set; } - - /// - /// Gets or sets the IP address of the next hop of the effective route. - /// - [JsonProperty(PropertyName = "nextHopIpAddress")] - public IList NextHopIpAddress { get; set; } - - /// - /// Gets or sets the type of Azure hop the packet should be sent to. - /// Possible values are: 'VirtualNetworkGateway', 'VnetLocal', - /// 'Internet', 'VirtualAppliance', and 'None'. Possible values - /// include: 'VirtualNetworkGateway', 'VnetLocal', 'Internet', - /// 'VirtualAppliance', 'None' - /// - [JsonProperty(PropertyName = "nextHopType")] - public string NextHopType { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveRouteListResult.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveRouteListResult.cs index 17d691bf9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveRouteListResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveRouteListResult.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response for list effective route API service call. - /// - public partial class EffectiveRouteListResult - { - /// - /// Initializes a new instance of the EffectiveRouteListResult class. - /// - public EffectiveRouteListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EffectiveRouteListResult class. - /// - /// A list of effective routes. - /// The URL to get the next set of - /// results. - public EffectiveRouteListResult(IList value = default(IList), string nextLink = default(string)) - { - Value = value; - NextLink = nextLink; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a list of effective routes. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - /// - /// Gets or sets the URL to get the next set of results. - /// - [JsonProperty(PropertyName = "nextLink")] - public string NextLink { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveRouteSource.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveRouteSource.cs index 6d950b6df..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveRouteSource.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveRouteSource.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for EffectiveRouteSource. - /// - public static class EffectiveRouteSource - { - public const string Unknown = "Unknown"; - public const string User = "User"; - public const string VirtualNetworkGateway = "VirtualNetworkGateway"; - public const string Default = "Default"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/EffectiveRouteState.cs b/Samples/test/end-to-end/network/Client/Models/EffectiveRouteState.cs index 52f6fbbe0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/EffectiveRouteState.cs +++ b/Samples/test/end-to-end/network/Client/Models/EffectiveRouteState.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for EffectiveRouteState. - /// - public static class EffectiveRouteState - { - public const string Active = "Active"; - public const string Invalid = "Invalid"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Error.cs b/Samples/test/end-to-end/network/Client/Models/Error.cs index 28fefee44..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Error.cs +++ b/Samples/test/end-to-end/network/Client/Models/Error.cs @@ -1,68 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Error - { - /// - /// Initializes a new instance of the Error class. - /// - public Error() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Error class. - /// - public Error(string code = default(string), string message = default(string), string target = default(string), IList details = default(IList), string innerError = default(string)) - { - Code = code; - Message = message; - Target = target; - Details = details; - InnerError = innerError; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "code")] - public string Code { get; set; } - - /// - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - /// - /// - [JsonProperty(PropertyName = "target")] - public string Target { get; set; } - - /// - /// - [JsonProperty(PropertyName = "details")] - public IList Details { get; set; } - - /// - /// - [JsonProperty(PropertyName = "innerError")] - public string InnerError { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ErrorDetails.cs b/Samples/test/end-to-end/network/Client/Models/ErrorDetails.cs index 4370c9bc6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ErrorDetails.cs +++ b/Samples/test/end-to-end/network/Client/Models/ErrorDetails.cs @@ -1,54 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class ErrorDetails - { - /// - /// Initializes a new instance of the ErrorDetails class. - /// - public ErrorDetails() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ErrorDetails class. - /// - public ErrorDetails(string code = default(string), string target = default(string), string message = default(string)) - { - Code = code; - Target = target; - Message = message; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "code")] - public string Code { get; set; } - - /// - /// - [JsonProperty(PropertyName = "target")] - public string Target { get; set; } - - /// - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuit.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuit.cs index a3862ad8d..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuit.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuit.cs @@ -1,162 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// ExpressRouteCircuit resource - /// - [JsonTransformation] - public partial class ExpressRouteCircuit : Resource - { - /// - /// Initializes a new instance of the ExpressRouteCircuit class. - /// - public ExpressRouteCircuit() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuit class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// The SKU. - /// Allow classic - /// operations - /// The CircuitProvisioningState - /// state of the resource. - /// The - /// ServiceProviderProvisioningState state of the resource. Possible - /// values are 'NotProvisioned', 'Provisioning', 'Provisioned', and - /// 'Deprovisioning'. Possible values include: 'NotProvisioned', - /// 'Provisioning', 'Provisioned', 'Deprovisioning' - /// The list of authorizations. - /// The list of peerings. - /// The ServiceKey. - /// The - /// ServiceProviderNotes. - /// The - /// ServiceProviderProperties. - /// Gets the provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// The GatewayManager Etag. - /// Gets a unique read-only string that changes - /// whenever the resource is updated. - public ExpressRouteCircuit(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ExpressRouteCircuitSku sku = default(ExpressRouteCircuitSku), bool? allowClassicOperations = default(bool?), string circuitProvisioningState = default(string), string serviceProviderProvisioningState = default(string), IList authorizations = default(IList), IList peerings = default(IList), string serviceKey = default(string), string serviceProviderNotes = default(string), ExpressRouteCircuitServiceProviderProperties serviceProviderProperties = default(ExpressRouteCircuitServiceProviderProperties), string provisioningState = default(string), string gatewayManagerEtag = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - Sku = sku; - AllowClassicOperations = allowClassicOperations; - CircuitProvisioningState = circuitProvisioningState; - ServiceProviderProvisioningState = serviceProviderProvisioningState; - Authorizations = authorizations; - Peerings = peerings; - ServiceKey = serviceKey; - ServiceProviderNotes = serviceProviderNotes; - ServiceProviderProperties = serviceProviderProperties; - ProvisioningState = provisioningState; - GatewayManagerEtag = gatewayManagerEtag; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the SKU. - /// - [JsonProperty(PropertyName = "sku")] - public ExpressRouteCircuitSku Sku { get; set; } - - /// - /// Gets or sets allow classic operations - /// - [JsonProperty(PropertyName = "properties.allowClassicOperations")] - public bool? AllowClassicOperations { get; set; } - - /// - /// Gets or sets the CircuitProvisioningState state of the resource. - /// - [JsonProperty(PropertyName = "properties.circuitProvisioningState")] - public string CircuitProvisioningState { get; set; } - - /// - /// Gets or sets the ServiceProviderProvisioningState state of the - /// resource. Possible values are 'NotProvisioned', 'Provisioning', - /// 'Provisioned', and 'Deprovisioning'. Possible values include: - /// 'NotProvisioned', 'Provisioning', 'Provisioned', 'Deprovisioning' - /// - [JsonProperty(PropertyName = "properties.serviceProviderProvisioningState")] - public string ServiceProviderProvisioningState { get; set; } - - /// - /// Gets or sets the list of authorizations. - /// - [JsonProperty(PropertyName = "properties.authorizations")] - public IList Authorizations { get; set; } - - /// - /// Gets or sets the list of peerings. - /// - [JsonProperty(PropertyName = "properties.peerings")] - public IList Peerings { get; set; } - - /// - /// Gets or sets the ServiceKey. - /// - [JsonProperty(PropertyName = "properties.serviceKey")] - public string ServiceKey { get; set; } - - /// - /// Gets or sets the ServiceProviderNotes. - /// - [JsonProperty(PropertyName = "properties.serviceProviderNotes")] - public string ServiceProviderNotes { get; set; } - - /// - /// Gets or sets the ServiceProviderProperties. - /// - [JsonProperty(PropertyName = "properties.serviceProviderProperties")] - public ExpressRouteCircuitServiceProviderProperties ServiceProviderProperties { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the GatewayManager Etag. - /// - [JsonProperty(PropertyName = "properties.gatewayManagerEtag")] - public string GatewayManagerEtag { get; set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitArpTable.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitArpTable.cs index 865c2ef5e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitArpTable.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitArpTable.cs @@ -1,73 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The ARP table associated with the ExpressRouteCircuit. - /// - public partial class ExpressRouteCircuitArpTable - { - /// - /// Initializes a new instance of the ExpressRouteCircuitArpTable - /// class. - /// - public ExpressRouteCircuitArpTable() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuitArpTable - /// class. - /// - /// Age - /// Interface - /// The IP address. - /// The MAC address. - public ExpressRouteCircuitArpTable(int? age = default(int?), string interfaceProperty = default(string), string ipAddress = default(string), string macAddress = default(string)) - { - Age = age; - InterfaceProperty = interfaceProperty; - IpAddress = ipAddress; - MacAddress = macAddress; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets age - /// - [JsonProperty(PropertyName = "age")] - public int? Age { get; set; } - - /// - /// Gets or sets interface - /// - [JsonProperty(PropertyName = "interface")] - public string InterfaceProperty { get; set; } - - /// - /// Gets or sets the IP address. - /// - [JsonProperty(PropertyName = "ipAddress")] - public string IpAddress { get; set; } - - /// - /// Gets or sets the MAC address. - /// - [JsonProperty(PropertyName = "macAddress")] - public string MacAddress { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitAuthorization.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitAuthorization.cs index 939d63a46..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitAuthorization.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitAuthorization.cs @@ -1,98 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Authorization in an ExpressRouteCircuit resource. - /// - [JsonTransformation] - public partial class ExpressRouteCircuitAuthorization : SubResource - { - /// - /// Initializes a new instance of the ExpressRouteCircuitAuthorization - /// class. - /// - public ExpressRouteCircuitAuthorization() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuitAuthorization - /// class. - /// - /// Resource ID. - /// The authorization key. - /// AuthorizationUseStatus. - /// Possible values are: 'Available' and 'InUse'. Possible values - /// include: 'Available', 'InUse' - /// Gets the provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// Gets name of the resource that is unique within - /// a resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ExpressRouteCircuitAuthorization(string id = default(string), string authorizationKey = default(string), string authorizationUseStatus = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - AuthorizationKey = authorizationKey; - AuthorizationUseStatus = authorizationUseStatus; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the authorization key. - /// - [JsonProperty(PropertyName = "properties.authorizationKey")] - public string AuthorizationKey { get; set; } - - /// - /// Gets or sets authorizationUseStatus. Possible values are: - /// 'Available' and 'InUse'. Possible values include: 'Available', - /// 'InUse' - /// - [JsonProperty(PropertyName = "properties.authorizationUseStatus")] - public string AuthorizationUseStatus { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets name of the resource that is unique within a resource group. - /// This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeering.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeering.cs index 7708eeaec..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeering.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeering.cs @@ -1,211 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Peering in an ExpressRouteCircuit resource. - /// - [JsonTransformation] - public partial class ExpressRouteCircuitPeering : SubResource - { - /// - /// Initializes a new instance of the ExpressRouteCircuitPeering class. - /// - public ExpressRouteCircuitPeering() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuitPeering class. - /// - /// Resource ID. - /// The PeeringType. Possible values are: - /// 'AzurePublicPeering', 'AzurePrivatePeering', and - /// 'MicrosoftPeering'. Possible values include: 'AzurePublicPeering', - /// 'AzurePrivatePeering', 'MicrosoftPeering' - /// The state of peering. Possible values are: - /// 'Disabled' and 'Enabled'. Possible values include: 'Disabled', - /// 'Enabled' - /// The Azure ASN. - /// The peer ASN. - /// The primary address - /// prefix. - /// The secondary address - /// prefix. - /// The primary port. - /// The secondary port. - /// The shared key. - /// The VLAN ID. - /// The Microsoft peering - /// configuration. - /// Gets peering stats. - /// Gets the provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// The GatewayManager Etag. - /// Gets whether the provider or the - /// customer last modified the peering. - /// The reference of the RouteFilter - /// resource. - /// Gets name of the resource that is unique within - /// a resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ExpressRouteCircuitPeering(string id = default(string), string peeringType = default(string), string state = default(string), int? azureASN = default(int?), int? peerASN = default(int?), string primaryPeerAddressPrefix = default(string), string secondaryPeerAddressPrefix = default(string), string primaryAzurePort = default(string), string secondaryAzurePort = default(string), string sharedKey = default(string), int? vlanId = default(int?), ExpressRouteCircuitPeeringConfig microsoftPeeringConfig = default(ExpressRouteCircuitPeeringConfig), ExpressRouteCircuitStats stats = default(ExpressRouteCircuitStats), string provisioningState = default(string), string gatewayManagerEtag = default(string), string lastModifiedBy = default(string), RouteFilter routeFilter = default(RouteFilter), string name = default(string), string etag = default(string)) - : base(id) - { - PeeringType = peeringType; - State = state; - AzureASN = azureASN; - PeerASN = peerASN; - PrimaryPeerAddressPrefix = primaryPeerAddressPrefix; - SecondaryPeerAddressPrefix = secondaryPeerAddressPrefix; - PrimaryAzurePort = primaryAzurePort; - SecondaryAzurePort = secondaryAzurePort; - SharedKey = sharedKey; - VlanId = vlanId; - MicrosoftPeeringConfig = microsoftPeeringConfig; - Stats = stats; - ProvisioningState = provisioningState; - GatewayManagerEtag = gatewayManagerEtag; - LastModifiedBy = lastModifiedBy; - RouteFilter = routeFilter; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the PeeringType. Possible values are: - /// 'AzurePublicPeering', 'AzurePrivatePeering', and - /// 'MicrosoftPeering'. Possible values include: 'AzurePublicPeering', - /// 'AzurePrivatePeering', 'MicrosoftPeering' - /// - [JsonProperty(PropertyName = "properties.peeringType")] - public string PeeringType { get; set; } - - /// - /// Gets or sets the state of peering. Possible values are: 'Disabled' - /// and 'Enabled'. Possible values include: 'Disabled', 'Enabled' - /// - [JsonProperty(PropertyName = "properties.state")] - public string State { get; set; } - - /// - /// Gets or sets the Azure ASN. - /// - [JsonProperty(PropertyName = "properties.azureASN")] - public int? AzureASN { get; set; } - - /// - /// Gets or sets the peer ASN. - /// - [JsonProperty(PropertyName = "properties.peerASN")] - public int? PeerASN { get; set; } - - /// - /// Gets or sets the primary address prefix. - /// - [JsonProperty(PropertyName = "properties.primaryPeerAddressPrefix")] - public string PrimaryPeerAddressPrefix { get; set; } - - /// - /// Gets or sets the secondary address prefix. - /// - [JsonProperty(PropertyName = "properties.secondaryPeerAddressPrefix")] - public string SecondaryPeerAddressPrefix { get; set; } - - /// - /// Gets or sets the primary port. - /// - [JsonProperty(PropertyName = "properties.primaryAzurePort")] - public string PrimaryAzurePort { get; set; } - - /// - /// Gets or sets the secondary port. - /// - [JsonProperty(PropertyName = "properties.secondaryAzurePort")] - public string SecondaryAzurePort { get; set; } - - /// - /// Gets or sets the shared key. - /// - [JsonProperty(PropertyName = "properties.sharedKey")] - public string SharedKey { get; set; } - - /// - /// Gets or sets the VLAN ID. - /// - [JsonProperty(PropertyName = "properties.vlanId")] - public int? VlanId { get; set; } - - /// - /// Gets or sets the Microsoft peering configuration. - /// - [JsonProperty(PropertyName = "properties.microsoftPeeringConfig")] - public ExpressRouteCircuitPeeringConfig MicrosoftPeeringConfig { get; set; } - - /// - /// Gets peering stats. - /// - [JsonProperty(PropertyName = "properties.stats")] - public ExpressRouteCircuitStats Stats { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the GatewayManager Etag. - /// - [JsonProperty(PropertyName = "properties.gatewayManagerEtag")] - public string GatewayManagerEtag { get; set; } - - /// - /// Gets whether the provider or the customer last modified the - /// peering. - /// - [JsonProperty(PropertyName = "properties.lastModifiedBy")] - public string LastModifiedBy { get; set; } - - /// - /// Gets or sets the reference of the RouteFilter resource. - /// - [JsonProperty(PropertyName = "properties.routeFilter")] - public RouteFilter RouteFilter { get; set; } - - /// - /// Gets name of the resource that is unique within a resource group. - /// This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringAdvertisedPublicPrefixState.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringAdvertisedPublicPrefixState.cs index e052e0300..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringAdvertisedPublicPrefixState.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringAdvertisedPublicPrefixState.cs @@ -1,21 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for - /// ExpressRouteCircuitPeeringAdvertisedPublicPrefixState. - /// - public static class ExpressRouteCircuitPeeringAdvertisedPublicPrefixState - { - public const string NotConfigured = "NotConfigured"; - public const string Configuring = "Configuring"; - public const string Configured = "Configured"; - public const string ValidationNeeded = "ValidationNeeded"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringConfig.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringConfig.cs index 82d5734c5..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringConfig.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringConfig.cs @@ -1,85 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Specifies the peering configuration. - /// - public partial class ExpressRouteCircuitPeeringConfig - { - /// - /// Initializes a new instance of the ExpressRouteCircuitPeeringConfig - /// class. - /// - public ExpressRouteCircuitPeeringConfig() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuitPeeringConfig - /// class. - /// - /// The reference of - /// AdvertisedPublicPrefixes. - /// AdvertisedPublicPrefixState of - /// the Peering resource. Possible values are 'NotConfigured', - /// 'Configuring', 'Configured', and 'ValidationNeeded'. Possible - /// values include: 'NotConfigured', 'Configuring', 'Configured', - /// 'ValidationNeeded' - /// The CustomerASN of the peering. - /// The RoutingRegistryName of the - /// configuration. - public ExpressRouteCircuitPeeringConfig(IList advertisedPublicPrefixes = default(IList), string advertisedPublicPrefixesState = default(string), int? customerASN = default(int?), string routingRegistryName = default(string)) - { - AdvertisedPublicPrefixes = advertisedPublicPrefixes; - AdvertisedPublicPrefixesState = advertisedPublicPrefixesState; - CustomerASN = customerASN; - RoutingRegistryName = routingRegistryName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the reference of AdvertisedPublicPrefixes. - /// - [JsonProperty(PropertyName = "advertisedPublicPrefixes")] - public IList AdvertisedPublicPrefixes { get; set; } - - /// - /// Gets or sets advertisedPublicPrefixState of the Peering resource. - /// Possible values are 'NotConfigured', 'Configuring', 'Configured', - /// and 'ValidationNeeded'. Possible values include: 'NotConfigured', - /// 'Configuring', 'Configured', 'ValidationNeeded' - /// - [JsonProperty(PropertyName = "advertisedPublicPrefixesState")] - public string AdvertisedPublicPrefixesState { get; set; } - - /// - /// Gets or sets the CustomerASN of the peering. - /// - [JsonProperty(PropertyName = "customerASN")] - public int? CustomerASN { get; set; } - - /// - /// Gets or sets the RoutingRegistryName of the configuration. - /// - [JsonProperty(PropertyName = "routingRegistryName")] - public string RoutingRegistryName { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringState.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringState.cs index 14a023e65..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringState.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringState.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ExpressRouteCircuitPeeringState. - /// - public static class ExpressRouteCircuitPeeringState - { - public const string Disabled = "Disabled"; - public const string Enabled = "Enabled"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringType.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringType.cs index 86e8714f7..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringType.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitPeeringType.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ExpressRouteCircuitPeeringType. - /// - public static class ExpressRouteCircuitPeeringType - { - public const string AzurePublicPeering = "AzurePublicPeering"; - public const string AzurePrivatePeering = "AzurePrivatePeering"; - public const string MicrosoftPeering = "MicrosoftPeering"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTable.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTable.cs index 340630af9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTable.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTable.cs @@ -1,81 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The routes table associated with the ExpressRouteCircuit - /// - public partial class ExpressRouteCircuitRoutesTable - { - /// - /// Initializes a new instance of the ExpressRouteCircuitRoutesTable - /// class. - /// - public ExpressRouteCircuitRoutesTable() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuitRoutesTable - /// class. - /// - /// network - /// nextHop - /// locPrf - /// weight. - /// path - public ExpressRouteCircuitRoutesTable(string networkProperty = default(string), string nextHop = default(string), string locPrf = default(string), int? weight = default(int?), string path = default(string)) - { - NetworkProperty = networkProperty; - NextHop = nextHop; - LocPrf = locPrf; - Weight = weight; - Path = path; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets network - /// - [JsonProperty(PropertyName = "network")] - public string NetworkProperty { get; set; } - - /// - /// Gets or sets nextHop - /// - [JsonProperty(PropertyName = "nextHop")] - public string NextHop { get; set; } - - /// - /// Gets or sets locPrf - /// - [JsonProperty(PropertyName = "locPrf")] - public string LocPrf { get; set; } - - /// - /// Gets or sets weight. - /// - [JsonProperty(PropertyName = "weight")] - public int? Weight { get; set; } - - /// - /// Gets or sets path - /// - [JsonProperty(PropertyName = "path")] - public string Path { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTableSummary.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTableSummary.cs index e1c934b70..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTableSummary.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitRoutesTableSummary.cs @@ -1,88 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The routes table associated with the ExpressRouteCircuit. - /// - public partial class ExpressRouteCircuitRoutesTableSummary - { - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitRoutesTableSummary class. - /// - public ExpressRouteCircuitRoutesTableSummary() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitRoutesTableSummary class. - /// - /// Neighbor - /// BGP version number spoken to the neighbor. - /// Autonomous system number. - /// The length of time that the BGP session has - /// been in the Established state, or the current status if not in the - /// Established state. - /// Current state of the BGP session, and the - /// number of prefixes that have been received from a neighbor or peer - /// group. - public ExpressRouteCircuitRoutesTableSummary(string neighbor = default(string), int? v = default(int?), int? asProperty = default(int?), string upDown = default(string), string statePfxRcd = default(string)) - { - Neighbor = neighbor; - V = v; - AsProperty = asProperty; - UpDown = upDown; - StatePfxRcd = statePfxRcd; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets neighbor - /// - [JsonProperty(PropertyName = "neighbor")] - public string Neighbor { get; set; } - - /// - /// Gets or sets BGP version number spoken to the neighbor. - /// - [JsonProperty(PropertyName = "v")] - public int? V { get; set; } - - /// - /// Gets or sets autonomous system number. - /// - [JsonProperty(PropertyName = "as")] - public int? AsProperty { get; set; } - - /// - /// Gets or sets the length of time that the BGP session has been in - /// the Established state, or the current status if not in the - /// Established state. - /// - [JsonProperty(PropertyName = "upDown")] - public string UpDown { get; set; } - - /// - /// Gets or sets current state of the BGP session, and the number of - /// prefixes that have been received from a neighbor or peer group. - /// - [JsonProperty(PropertyName = "statePfxRcd")] - public string StatePfxRcd { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitServiceProviderProperties.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitServiceProviderProperties.cs index e57a6bd53..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitServiceProviderProperties.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitServiceProviderProperties.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Contains ServiceProviderProperties in an ExpressRouteCircuit. - /// - public partial class ExpressRouteCircuitServiceProviderProperties - { - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitServiceProviderProperties class. - /// - public ExpressRouteCircuitServiceProviderProperties() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitServiceProviderProperties class. - /// - /// The serviceProviderName. - /// The peering location. - /// The BandwidthInMbps. - public ExpressRouteCircuitServiceProviderProperties(string serviceProviderName = default(string), string peeringLocation = default(string), int? bandwidthInMbps = default(int?)) - { - ServiceProviderName = serviceProviderName; - PeeringLocation = peeringLocation; - BandwidthInMbps = bandwidthInMbps; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the serviceProviderName. - /// - [JsonProperty(PropertyName = "serviceProviderName")] - public string ServiceProviderName { get; set; } - - /// - /// Gets or sets the peering location. - /// - [JsonProperty(PropertyName = "peeringLocation")] - public string PeeringLocation { get; set; } - - /// - /// Gets or sets the BandwidthInMbps. - /// - [JsonProperty(PropertyName = "bandwidthInMbps")] - public int? BandwidthInMbps { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSku.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSku.cs index 99e1a2edf..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSku.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSku.cs @@ -1,70 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Contains SKU in an ExpressRouteCircuit. - /// - public partial class ExpressRouteCircuitSku - { - /// - /// Initializes a new instance of the ExpressRouteCircuitSku class. - /// - public ExpressRouteCircuitSku() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuitSku class. - /// - /// The name of the SKU. - /// The tier of the SKU. Possible values are - /// 'Standard' and 'Premium'. Possible values include: 'Standard', - /// 'Premium' - /// The family of the SKU. Possible values are: - /// 'UnlimitedData' and 'MeteredData'. Possible values include: - /// 'UnlimitedData', 'MeteredData' - public ExpressRouteCircuitSku(string name = default(string), string tier = default(string), string family = default(string)) - { - Name = name; - Tier = tier; - Family = family; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the SKU. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the tier of the SKU. Possible values are 'Standard' - /// and 'Premium'. Possible values include: 'Standard', 'Premium' - /// - [JsonProperty(PropertyName = "tier")] - public string Tier { get; set; } - - /// - /// Gets or sets the family of the SKU. Possible values are: - /// 'UnlimitedData' and 'MeteredData'. Possible values include: - /// 'UnlimitedData', 'MeteredData' - /// - [JsonProperty(PropertyName = "family")] - public string Family { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuFamily.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuFamily.cs index d63c62e4e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuFamily.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuFamily.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ExpressRouteCircuitSkuFamily. - /// - public static class ExpressRouteCircuitSkuFamily - { - public const string UnlimitedData = "UnlimitedData"; - public const string MeteredData = "MeteredData"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuTier.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuTier.cs index 9d0bdee07..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuTier.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitSkuTier.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ExpressRouteCircuitSkuTier. - /// - public static class ExpressRouteCircuitSkuTier - { - public const string Standard = "Standard"; - public const string Premium = "Premium"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitStats.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitStats.cs index e3f362954..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitStats.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitStats.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Contains stats associated with the peering. - /// - public partial class ExpressRouteCircuitStats - { - /// - /// Initializes a new instance of the ExpressRouteCircuitStats class. - /// - public ExpressRouteCircuitStats() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteCircuitStats class. - /// - /// Gets BytesIn of the peering. - /// Gets BytesOut of the peering. - /// Gets BytesIn of the peering. - /// Gets BytesOut of the - /// peering. - public ExpressRouteCircuitStats(long? primarybytesIn = default(long?), long? primarybytesOut = default(long?), long? secondarybytesIn = default(long?), long? secondarybytesOut = default(long?)) - { - PrimarybytesIn = primarybytesIn; - PrimarybytesOut = primarybytesOut; - SecondarybytesIn = secondarybytesIn; - SecondarybytesOut = secondarybytesOut; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets BytesIn of the peering. - /// - [JsonProperty(PropertyName = "primarybytesIn")] - public long? PrimarybytesIn { get; set; } - - /// - /// Gets BytesOut of the peering. - /// - [JsonProperty(PropertyName = "primarybytesOut")] - public long? PrimarybytesOut { get; set; } - - /// - /// Gets BytesIn of the peering. - /// - [JsonProperty(PropertyName = "secondarybytesIn")] - public long? SecondarybytesIn { get; set; } - - /// - /// Gets BytesOut of the peering. - /// - [JsonProperty(PropertyName = "secondarybytesOut")] - public long? SecondarybytesOut { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsArpTableListResult.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsArpTableListResult.cs index 5d1614f3f..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsArpTableListResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsArpTableListResult.cs @@ -1,61 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response for ListArpTable associated with the Express Route Circuits - /// API. - /// - public partial class ExpressRouteCircuitsArpTableListResult - { - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitsArpTableListResult class. - /// - public ExpressRouteCircuitsArpTableListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitsArpTableListResult class. - /// - /// Gets list of the ARP table. - /// The URL to get the next set of - /// results. - public ExpressRouteCircuitsArpTableListResult(IList value = default(IList), string nextLink = default(string)) - { - Value = value; - NextLink = nextLink; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of the ARP table. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - /// - /// Gets or sets the URL to get the next set of results. - /// - [JsonProperty(PropertyName = "nextLink")] - public string NextLink { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableListResult.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableListResult.cs index 4a278c623..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableListResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableListResult.cs @@ -1,61 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response for ListRoutesTable associated with the Express Route Circuits - /// API. - /// - public partial class ExpressRouteCircuitsRoutesTableListResult - { - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitsRoutesTableListResult class. - /// - public ExpressRouteCircuitsRoutesTableListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitsRoutesTableListResult class. - /// - /// The list of routes table. - /// The URL to get the next set of - /// results. - public ExpressRouteCircuitsRoutesTableListResult(IList value = default(IList), string nextLink = default(string)) - { - Value = value; - NextLink = nextLink; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the list of routes table. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - /// - /// Gets or sets the URL to get the next set of results. - /// - [JsonProperty(PropertyName = "nextLink")] - public string NextLink { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableSummaryListResult.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableSummaryListResult.cs index 9443c0c20..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableSummaryListResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteCircuitsRoutesTableSummaryListResult.cs @@ -1,61 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response for ListRoutesTable associated with the Express Route Circuits - /// API. - /// - public partial class ExpressRouteCircuitsRoutesTableSummaryListResult - { - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitsRoutesTableSummaryListResult class. - /// - public ExpressRouteCircuitsRoutesTableSummaryListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ExpressRouteCircuitsRoutesTableSummaryListResult class. - /// - /// A list of the routes table. - /// The URL to get the next set of - /// results. - public ExpressRouteCircuitsRoutesTableSummaryListResult(IList value = default(IList), string nextLink = default(string)) - { - Value = value; - NextLink = nextLink; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a list of the routes table. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - /// - /// Gets or sets the URL to get the next set of results. - /// - [JsonProperty(PropertyName = "nextLink")] - public string NextLink { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProvider.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProvider.cs index 95b7ba596..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProvider.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProvider.cs @@ -1,78 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A ExpressRouteResourceProvider object. - /// - [JsonTransformation] - public partial class ExpressRouteServiceProvider : Resource - { - /// - /// Initializes a new instance of the ExpressRouteServiceProvider - /// class. - /// - public ExpressRouteServiceProvider() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ExpressRouteServiceProvider - /// class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// Get a list of peering - /// locations. - /// Gets bandwidths offered. - /// Gets the provisioning state of the - /// resource. - public ExpressRouteServiceProvider(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IList peeringLocations = default(IList), IList bandwidthsOffered = default(IList), string provisioningState = default(string)) - : base(id, name, type, location, tags) - { - PeeringLocations = peeringLocations; - BandwidthsOffered = bandwidthsOffered; - ProvisioningState = provisioningState; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets get a list of peering locations. - /// - [JsonProperty(PropertyName = "properties.peeringLocations")] - public IList PeeringLocations { get; set; } - - /// - /// Gets bandwidths offered. - /// - [JsonProperty(PropertyName = "properties.bandwidthsOffered")] - public IList BandwidthsOffered { get; set; } - - /// - /// Gets the provisioning state of the resource. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProviderBandwidthsOffered.cs b/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProviderBandwidthsOffered.cs index 0f70a9501..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProviderBandwidthsOffered.cs +++ b/Samples/test/end-to-end/network/Client/Models/ExpressRouteServiceProviderBandwidthsOffered.cs @@ -1,57 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Contains bandwidths offered in ExpressRouteServiceProvider resources. - /// - public partial class ExpressRouteServiceProviderBandwidthsOffered - { - /// - /// Initializes a new instance of the - /// ExpressRouteServiceProviderBandwidthsOffered class. - /// - public ExpressRouteServiceProviderBandwidthsOffered() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ExpressRouteServiceProviderBandwidthsOffered class. - /// - /// The OfferName. - /// The ValueInMbps. - public ExpressRouteServiceProviderBandwidthsOffered(string offerName = default(string), int? valueInMbps = default(int?)) - { - OfferName = offerName; - ValueInMbps = valueInMbps; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the OfferName. - /// - [JsonProperty(PropertyName = "offerName")] - public string OfferName { get; set; } - - /// - /// Gets or sets the ValueInMbps. - /// - [JsonProperty(PropertyName = "valueInMbps")] - public int? ValueInMbps { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/FlowLogInformation.cs b/Samples/test/end-to-end/network/Client/Models/FlowLogInformation.cs index 7f3351511..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/FlowLogInformation.cs +++ b/Samples/test/end-to-end/network/Client/Models/FlowLogInformation.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Information on the configuration of flow log. - /// - [JsonTransformation] - public partial class FlowLogInformation - { - /// - /// Initializes a new instance of the FlowLogInformation class. - /// - public FlowLogInformation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the FlowLogInformation class. - /// - /// The ID of the resource to configure - /// for flow logging. - /// ID of the storage account which is used to - /// store the flow log. - /// Flag to enable/disable flow logging. - public FlowLogInformation(string targetResourceId, string storageId, bool enabled, RetentionPolicyParameters retentionPolicy = default(RetentionPolicyParameters)) - { - TargetResourceId = targetResourceId; - StorageId = storageId; - Enabled = enabled; - RetentionPolicy = retentionPolicy; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the ID of the resource to configure for flow logging. - /// - [JsonProperty(PropertyName = "targetResourceId")] - public string TargetResourceId { get; set; } - - /// - /// Gets or sets ID of the storage account which is used to store the - /// flow log. - /// - [JsonProperty(PropertyName = "properties.storageId")] - public string StorageId { get; set; } - - /// - /// Gets or sets flag to enable/disable flow logging. - /// - [JsonProperty(PropertyName = "properties.enabled")] - public bool Enabled { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.retentionPolicy")] - public RetentionPolicyParameters RetentionPolicy { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceId"); - } - if (StorageId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "StorageId"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/FlowLogStatusParameters.cs b/Samples/test/end-to-end/network/Client/Models/FlowLogStatusParameters.cs index 1901db8c8..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/FlowLogStatusParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/FlowLogStatusParameters.cs @@ -1,63 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define a resource to query flow log status. - /// - public partial class FlowLogStatusParameters - { - /// - /// Initializes a new instance of the FlowLogStatusParameters class. - /// - public FlowLogStatusParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the FlowLogStatusParameters class. - /// - /// The target resource where getting - /// the flow logging status. - public FlowLogStatusParameters(string targetResourceId) - { - TargetResourceId = targetResourceId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the target resource where getting the flow logging - /// status. - /// - [JsonProperty(PropertyName = "targetResourceId")] - public string TargetResourceId { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceId"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/FrontendIPConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/FrontendIPConfiguration.cs index 98a0dbdec..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/FrontendIPConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/FrontendIPConfiguration.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Frontend IP address of the load balancer. - /// - [JsonTransformation] - public partial class FrontendIPConfiguration : SubResource - { - /// - /// Initializes a new instance of the FrontendIPConfiguration class. - /// - public FrontendIPConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the FrontendIPConfiguration class. - /// - /// Resource ID. - /// Read only. Inbound rules URIs that - /// use this frontend IP. - /// Read only. Inbound pools URIs that - /// use this frontend IP. - /// Read only. Outbound rules URIs that - /// use this frontend IP. - /// Gets load balancing rules URIs - /// that use this frontend IP. - /// The private IP address of the IP - /// configuration. - /// The Private IP allocation - /// method. Possible values are: 'Static' and 'Dynamic'. Possible - /// values include: 'Static', 'Dynamic' - /// The reference of the subnet resource. - /// The reference of the Public IP - /// resource. - /// Gets the provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public FrontendIPConfiguration(string id = default(string), IList inboundNatRules = default(IList), IList inboundNatPools = default(IList), IList outboundNatRules = default(IList), IList loadBalancingRules = default(IList), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), Subnet subnet = default(Subnet), PublicIPAddress publicIPAddress = default(PublicIPAddress), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - InboundNatRules = inboundNatRules; - InboundNatPools = inboundNatPools; - OutboundNatRules = outboundNatRules; - LoadBalancingRules = loadBalancingRules; - PrivateIPAddress = privateIPAddress; - PrivateIPAllocationMethod = privateIPAllocationMethod; - Subnet = subnet; - PublicIPAddress = publicIPAddress; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets read only. Inbound rules URIs that use this frontend IP. - /// - [JsonProperty(PropertyName = "properties.inboundNatRules")] - public IList InboundNatRules { get; private set; } - - /// - /// Gets read only. Inbound pools URIs that use this frontend IP. - /// - [JsonProperty(PropertyName = "properties.inboundNatPools")] - public IList InboundNatPools { get; private set; } - - /// - /// Gets read only. Outbound rules URIs that use this frontend IP. - /// - [JsonProperty(PropertyName = "properties.outboundNatRules")] - public IList OutboundNatRules { get; private set; } - - /// - /// Gets load balancing rules URIs that use this frontend IP. - /// - [JsonProperty(PropertyName = "properties.loadBalancingRules")] - public IList LoadBalancingRules { get; private set; } - - /// - /// Gets or sets the private IP address of the IP configuration. - /// - [JsonProperty(PropertyName = "properties.privateIPAddress")] - public string PrivateIPAddress { get; set; } - - /// - /// Gets or sets the Private IP allocation method. Possible values are: - /// 'Static' and 'Dynamic'. Possible values include: 'Static', - /// 'Dynamic' - /// - [JsonProperty(PropertyName = "properties.privateIPAllocationMethod")] - public string PrivateIPAllocationMethod { get; set; } - - /// - /// Gets or sets the reference of the subnet resource. - /// - [JsonProperty(PropertyName = "properties.subnet")] - public Subnet Subnet { get; set; } - - /// - /// Gets or sets the reference of the Public IP resource. - /// - [JsonProperty(PropertyName = "properties.publicIPAddress")] - public PublicIPAddress PublicIPAddress { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/GatewayRoute.cs b/Samples/test/end-to-end/network/Client/Models/GatewayRoute.cs index a542014ea..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/GatewayRoute.cs +++ b/Samples/test/end-to-end/network/Client/Models/GatewayRoute.cs @@ -1,93 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class GatewayRoute - { - /// - /// Initializes a new instance of the GatewayRoute class. - /// - public GatewayRoute() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the GatewayRoute class. - /// - /// The gateway's local address - /// The route's network prefix - /// The route's next hop - /// The peer this route was learned - /// from - /// The source this route was learned from - /// The route's AS path sequence - /// The route's weight - public GatewayRoute(string localAddress = default(string), string networkProperty = default(string), string nextHop = default(string), string sourcePeer = default(string), string origin = default(string), string asPath = default(string), int? weight = default(int?)) - { - LocalAddress = localAddress; - NetworkProperty = networkProperty; - NextHop = nextHop; - SourcePeer = sourcePeer; - Origin = origin; - AsPath = asPath; - Weight = weight; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the gateway's local address - /// - [JsonProperty(PropertyName = "localAddress")] - public string LocalAddress { get; private set; } - - /// - /// Gets the route's network prefix - /// - [JsonProperty(PropertyName = "network")] - public string NetworkProperty { get; private set; } - - /// - /// Gets the route's next hop - /// - [JsonProperty(PropertyName = "nextHop")] - public string NextHop { get; private set; } - - /// - /// Gets the peer this route was learned from - /// - [JsonProperty(PropertyName = "sourcePeer")] - public string SourcePeer { get; private set; } - - /// - /// Gets the source this route was learned from - /// - [JsonProperty(PropertyName = "origin")] - public string Origin { get; private set; } - - /// - /// Gets the route's AS path sequence - /// - [JsonProperty(PropertyName = "asPath")] - public string AsPath { get; private set; } - - /// - /// Gets the route's weight - /// - [JsonProperty(PropertyName = "weight")] - public int? Weight { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/GatewayRouteListResult.cs b/Samples/test/end-to-end/network/Client/Models/GatewayRouteListResult.cs index 3541ca8a4..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/GatewayRouteListResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/GatewayRouteListResult.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// List of virtual network gateway routes - /// - public partial class GatewayRouteListResult - { - /// - /// Initializes a new instance of the GatewayRouteListResult class. - /// - public GatewayRouteListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the GatewayRouteListResult class. - /// - /// List of gateway routes - public GatewayRouteListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets list of gateway routes - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/IPAddressAvailabilityResult.cs b/Samples/test/end-to-end/network/Client/Models/IPAddressAvailabilityResult.cs index 9e3895cc5..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/IPAddressAvailabilityResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/IPAddressAvailabilityResult.cs @@ -1,61 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Response for CheckIPAddressAvailability API service call - /// - public partial class IPAddressAvailabilityResult - { - /// - /// Initializes a new instance of the IPAddressAvailabilityResult - /// class. - /// - public IPAddressAvailabilityResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the IPAddressAvailabilityResult - /// class. - /// - /// Private IP address availability. - /// Contains other available private - /// IP addresses if the asked for address is taken. - public IPAddressAvailabilityResult(bool? available = default(bool?), IList availableIPAddresses = default(IList)) - { - Available = available; - AvailableIPAddresses = availableIPAddresses; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets private IP address availability. - /// - [JsonProperty(PropertyName = "available")] - public bool? Available { get; set; } - - /// - /// Gets or sets contains other available private IP addresses if the - /// asked for address is taken. - /// - [JsonProperty(PropertyName = "availableIPAddresses")] - public IList AvailableIPAddresses { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/IPAllocationMethod.cs b/Samples/test/end-to-end/network/Client/Models/IPAllocationMethod.cs index 18b247763..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/IPAllocationMethod.cs +++ b/Samples/test/end-to-end/network/Client/Models/IPAllocationMethod.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for IPAllocationMethod. - /// - public static class IPAllocationMethod - { - public const string Static = "Static"; - public const string Dynamic = "Dynamic"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/IPConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/IPConfiguration.cs index 835836dd6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/IPConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/IPConfiguration.cs @@ -1,114 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// IPConfiguration - /// - [JsonTransformation] - public partial class IPConfiguration : SubResource - { - /// - /// Initializes a new instance of the IPConfiguration class. - /// - public IPConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the IPConfiguration class. - /// - /// Resource ID. - /// The private IP address of the IP - /// configuration. - /// The private IP allocation - /// method. Possible values are 'Static' and 'Dynamic'. Possible values - /// include: 'Static', 'Dynamic' - /// The reference of the subnet resource. - /// The reference of the public IP - /// resource. - /// Gets the provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public IPConfiguration(string id = default(string), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), Subnet subnet = default(Subnet), PublicIPAddress publicIPAddress = default(PublicIPAddress), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - PrivateIPAddress = privateIPAddress; - PrivateIPAllocationMethod = privateIPAllocationMethod; - Subnet = subnet; - PublicIPAddress = publicIPAddress; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the private IP address of the IP configuration. - /// - [JsonProperty(PropertyName = "properties.privateIPAddress")] - public string PrivateIPAddress { get; set; } - - /// - /// Gets or sets the private IP allocation method. Possible values are - /// 'Static' and 'Dynamic'. Possible values include: 'Static', - /// 'Dynamic' - /// - [JsonProperty(PropertyName = "properties.privateIPAllocationMethod")] - public string PrivateIPAllocationMethod { get; set; } - - /// - /// Gets or sets the reference of the subnet resource. - /// - [JsonProperty(PropertyName = "properties.subnet")] - public Subnet Subnet { get; set; } - - /// - /// Gets or sets the reference of the public IP resource. - /// - [JsonProperty(PropertyName = "properties.publicIPAddress")] - public PublicIPAddress PublicIPAddress { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/IPVersion.cs b/Samples/test/end-to-end/network/Client/Models/IPVersion.cs index dca3c94d1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/IPVersion.cs +++ b/Samples/test/end-to-end/network/Client/Models/IPVersion.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for IPVersion. - /// - public static class IPVersion - { - public const string IPv4 = "IPv4"; - public const string IPv6 = "IPv6"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/InboundNatPool.cs b/Samples/test/end-to-end/network/Client/Models/InboundNatPool.cs index abd9d9133..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/InboundNatPool.cs +++ b/Samples/test/end-to-end/network/Client/Models/InboundNatPool.cs @@ -1,145 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Inbound NAT pool of the load balancer. - /// - [JsonTransformation] - public partial class InboundNatPool : SubResource - { - /// - /// Initializes a new instance of the InboundNatPool class. - /// - public InboundNatPool() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the InboundNatPool class. - /// - /// The transport protocol for the endpoint. - /// Possible values are: 'Udp' or 'Tcp'. Possible values include: - /// 'Udp', 'Tcp' - /// The first port number in the - /// range of external ports that will be used to provide Inbound Nat to - /// NICs associated with a load balancer. Acceptable values range - /// between 1 and 65534. - /// The last port number in the - /// range of external ports that will be used to provide Inbound Nat to - /// NICs associated with a load balancer. Acceptable values range - /// between 1 and 65535. - /// The port used for internal connections on - /// the endpoint. Acceptable values are between 1 and 65535. - /// Resource ID. - /// A reference to frontend IP - /// addresses. - /// Gets the provisioning state of the - /// PublicIP resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public InboundNatPool(string protocol, int frontendPortRangeStart, int frontendPortRangeEnd, int backendPort, string id = default(string), SubResource frontendIPConfiguration = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - FrontendIPConfiguration = frontendIPConfiguration; - Protocol = protocol; - FrontendPortRangeStart = frontendPortRangeStart; - FrontendPortRangeEnd = frontendPortRangeEnd; - BackendPort = backendPort; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a reference to frontend IP addresses. - /// - [JsonProperty(PropertyName = "properties.frontendIPConfiguration")] - public SubResource FrontendIPConfiguration { get; set; } - - /// - /// Gets or sets the transport protocol for the endpoint. Possible - /// values are: 'Udp' or 'Tcp'. Possible values include: 'Udp', 'Tcp' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets the first port number in the range of external ports - /// that will be used to provide Inbound Nat to NICs associated with a - /// load balancer. Acceptable values range between 1 and 65534. - /// - [JsonProperty(PropertyName = "properties.frontendPortRangeStart")] - public int FrontendPortRangeStart { get; set; } - - /// - /// Gets or sets the last port number in the range of external ports - /// that will be used to provide Inbound Nat to NICs associated with a - /// load balancer. Acceptable values range between 1 and 65535. - /// - [JsonProperty(PropertyName = "properties.frontendPortRangeEnd")] - public int FrontendPortRangeEnd { get; set; } - - /// - /// Gets or sets the port used for internal connections on the - /// endpoint. Acceptable values are between 1 and 65535. - /// - [JsonProperty(PropertyName = "properties.backendPort")] - public int BackendPort { get; set; } - - /// - /// Gets the provisioning state of the PublicIP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Protocol == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Protocol"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/InboundNatRule.cs b/Samples/test/end-to-end/network/Client/Models/InboundNatRule.cs index 99018a712..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/InboundNatRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/InboundNatRule.cs @@ -1,160 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Inbound NAT rule of the load balancer. - /// - [JsonTransformation] - public partial class InboundNatRule : SubResource - { - /// - /// Initializes a new instance of the InboundNatRule class. - /// - public InboundNatRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the InboundNatRule class. - /// - /// Resource ID. - /// A reference to frontend IP - /// addresses. - /// A reference to a private IP - /// address defined on a network interface of a VM. Traffic sent to the - /// frontend port of each of the frontend IP configurations is - /// forwarded to the backed IP. - /// The transport protocol for the endpoint. - /// Possible values are: 'Udp' or 'Tcp'. Possible values include: - /// 'Udp', 'Tcp' - /// The port for the external endpoint. Port - /// numbers for each Rule must be unique within the Load Balancer. - /// Acceptable values range from 1 to 65534. - /// The port used for the internal endpoint. - /// Acceptable values range from 1 to 65535. - /// The timeout for the TCP idle - /// connection. The value can be set between 4 and 30 minutes. The - /// default value is 4 minutes. This element is only used when the - /// protocol is set to TCP. - /// Configures a virtual machine's - /// endpoint for the floating IP capability required to configure a SQL - /// AlwaysOn Availability Group. This setting is required when using - /// the SQL AlwaysOn Availability Groups in SQL server. This setting - /// can't be changed after you create the endpoint. - /// Gets the provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// Gets name of the resource that is unique within - /// a resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public InboundNatRule(string id = default(string), SubResource frontendIPConfiguration = default(SubResource), NetworkInterfaceIPConfiguration backendIPConfiguration = default(NetworkInterfaceIPConfiguration), string protocol = default(string), int? frontendPort = default(int?), int? backendPort = default(int?), int? idleTimeoutInMinutes = default(int?), bool? enableFloatingIP = default(bool?), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - FrontendIPConfiguration = frontendIPConfiguration; - BackendIPConfiguration = backendIPConfiguration; - Protocol = protocol; - FrontendPort = frontendPort; - BackendPort = backendPort; - IdleTimeoutInMinutes = idleTimeoutInMinutes; - EnableFloatingIP = enableFloatingIP; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a reference to frontend IP addresses. - /// - [JsonProperty(PropertyName = "properties.frontendIPConfiguration")] - public SubResource FrontendIPConfiguration { get; set; } - - /// - /// Gets a reference to a private IP address defined on a network - /// interface of a VM. Traffic sent to the frontend port of each of the - /// frontend IP configurations is forwarded to the backed IP. - /// - [JsonProperty(PropertyName = "properties.backendIPConfiguration")] - public NetworkInterfaceIPConfiguration BackendIPConfiguration { get; private set; } - - /// - /// Gets or sets the transport protocol for the endpoint. Possible - /// values are: 'Udp' or 'Tcp'. Possible values include: 'Udp', 'Tcp' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets the port for the external endpoint. Port numbers for - /// each Rule must be unique within the Load Balancer. Acceptable - /// values range from 1 to 65534. - /// - [JsonProperty(PropertyName = "properties.frontendPort")] - public int? FrontendPort { get; set; } - - /// - /// Gets or sets the port used for the internal endpoint. Acceptable - /// values range from 1 to 65535. - /// - [JsonProperty(PropertyName = "properties.backendPort")] - public int? BackendPort { get; set; } - - /// - /// Gets or sets the timeout for the TCP idle connection. The value can - /// be set between 4 and 30 minutes. The default value is 4 minutes. - /// This element is only used when the protocol is set to TCP. - /// - [JsonProperty(PropertyName = "properties.idleTimeoutInMinutes")] - public int? IdleTimeoutInMinutes { get; set; } - - /// - /// Gets or sets configures a virtual machine's endpoint for the - /// floating IP capability required to configure a SQL AlwaysOn - /// Availability Group. This setting is required when using the SQL - /// AlwaysOn Availability Groups in SQL server. This setting can't be - /// changed after you create the endpoint. - /// - [JsonProperty(PropertyName = "properties.enableFloatingIP")] - public bool? EnableFloatingIP { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets name of the resource that is unique within a resource group. - /// This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/LoadBalancer.cs b/Samples/test/end-to-end/network/Client/Models/LoadBalancer.cs index b17accdd3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/LoadBalancer.cs +++ b/Samples/test/end-to-end/network/Client/Models/LoadBalancer.cs @@ -1,174 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// LoadBalancer resource - /// - [JsonTransformation] - public partial class LoadBalancer : Resource - { - /// - /// Initializes a new instance of the LoadBalancer class. - /// - public LoadBalancer() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the LoadBalancer class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// Object representing the - /// frontend IPs to be used for the load balancer - /// Collection of backend address - /// pools used by a load balancer - /// Object collection representing the - /// load balancing rules Gets the provisioning - /// Collection of probe objects used in the load - /// balancer - /// Collection of inbound NAT Rules used - /// by a load balancer. Defining inbound NAT rules on your load - /// balancer is mutually exclusive with defining an inbound NAT pool. - /// Inbound NAT pools are referenced from virtual machine scale sets. - /// NICs that are associated with individual virtual machines cannot - /// reference an Inbound NAT pool. They have to reference individual - /// inbound NAT rules. - /// Defines an external port range for - /// inbound NAT to a single backend port on NICs associated with a load - /// balancer. Inbound NAT rules are created automatically for each NIC - /// associated with the Load Balancer using an external port from this - /// range. Defining an Inbound NAT pool on your Load Balancer is - /// mutually exclusive with defining inbound Nat rules. Inbound NAT - /// pools are referenced from virtual machine scale sets. NICs that are - /// associated with individual virtual machines cannot reference an - /// inbound NAT pool. They have to reference individual inbound NAT - /// rules. - /// The outbound NAT rules. - /// The resource GUID property of the load - /// balancer resource. - /// Gets the provisioning state of the - /// PublicIP resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// A unique read-only string that changes whenever - /// the resource is updated. - public LoadBalancer(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IList frontendIPConfigurations = default(IList), IList backendAddressPools = default(IList), IList loadBalancingRules = default(IList), IList probes = default(IList), IList inboundNatRules = default(IList), IList inboundNatPools = default(IList), IList outboundNatRules = default(IList), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - FrontendIPConfigurations = frontendIPConfigurations; - BackendAddressPools = backendAddressPools; - LoadBalancingRules = loadBalancingRules; - Probes = probes; - InboundNatRules = inboundNatRules; - InboundNatPools = inboundNatPools; - OutboundNatRules = outboundNatRules; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets object representing the frontend IPs to be used for - /// the load balancer - /// - [JsonProperty(PropertyName = "properties.frontendIPConfigurations")] - public IList FrontendIPConfigurations { get; set; } - - /// - /// Gets or sets collection of backend address pools used by a load - /// balancer - /// - [JsonProperty(PropertyName = "properties.backendAddressPools")] - public IList BackendAddressPools { get; set; } - - /// - /// Gets or sets object collection representing the load balancing - /// rules Gets the provisioning - /// - [JsonProperty(PropertyName = "properties.loadBalancingRules")] - public IList LoadBalancingRules { get; set; } - - /// - /// Gets or sets collection of probe objects used in the load balancer - /// - [JsonProperty(PropertyName = "properties.probes")] - public IList Probes { get; set; } - - /// - /// Gets or sets collection of inbound NAT Rules used by a load - /// balancer. Defining inbound NAT rules on your load balancer is - /// mutually exclusive with defining an inbound NAT pool. Inbound NAT - /// pools are referenced from virtual machine scale sets. NICs that are - /// associated with individual virtual machines cannot reference an - /// Inbound NAT pool. They have to reference individual inbound NAT - /// rules. - /// - [JsonProperty(PropertyName = "properties.inboundNatRules")] - public IList InboundNatRules { get; set; } - - /// - /// Gets or sets defines an external port range for inbound NAT to a - /// single backend port on NICs associated with a load balancer. - /// Inbound NAT rules are created automatically for each NIC associated - /// with the Load Balancer using an external port from this range. - /// Defining an Inbound NAT pool on your Load Balancer is mutually - /// exclusive with defining inbound Nat rules. Inbound NAT pools are - /// referenced from virtual machine scale sets. NICs that are - /// associated with individual virtual machines cannot reference an - /// inbound NAT pool. They have to reference individual inbound NAT - /// rules. - /// - [JsonProperty(PropertyName = "properties.inboundNatPools")] - public IList InboundNatPools { get; set; } - - /// - /// Gets or sets the outbound NAT rules. - /// - [JsonProperty(PropertyName = "properties.outboundNatRules")] - public IList OutboundNatRules { get; set; } - - /// - /// Gets or sets the resource GUID property of the load balancer - /// resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets the provisioning state of the PublicIP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/LoadBalancingRule.cs b/Samples/test/end-to-end/network/Client/Models/LoadBalancingRule.cs index 0cba1464f..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/LoadBalancingRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/LoadBalancingRule.cs @@ -1,195 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A loag balancing rule for a load balancer. - /// - [JsonTransformation] - public partial class LoadBalancingRule : SubResource - { - /// - /// Initializes a new instance of the LoadBalancingRule class. - /// - public LoadBalancingRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the LoadBalancingRule class. - /// - /// The transport protocol for the external - /// endpoint. Possible values are 'Udp' or 'Tcp'. Possible values - /// include: 'Udp', 'Tcp' - /// The port for the external endpoint. Port - /// numbers for each Rule must be unique within the Load Balancer. - /// Acceptable values are between 1 and 65534. - /// Resource ID. - /// A reference to frontend IP - /// addresses. - /// A reference to a pool of DIPs. - /// Inbound traffic is randomly load balanced across IPs in the backend - /// IPs. - /// The reference of the load balancer probe used - /// by the load balancing rule. - /// The load distribution policy for - /// this rule. Possible values are 'Default', 'SourceIP', and - /// 'SourceIPProtocol'. Possible values include: 'Default', 'SourceIP', - /// 'SourceIPProtocol' - /// The port used for internal connections on - /// the endpoint. Acceptable values are between 1 and 65535. - /// The timeout for the TCP idle - /// connection. The value can be set between 4 and 30 minutes. The - /// default value is 4 minutes. This element is only used when the - /// protocol is set to TCP. - /// Configures a virtual machine's - /// endpoint for the floating IP capability required to configure a SQL - /// AlwaysOn Availability Group. This setting is required when using - /// the SQL AlwaysOn Availability Groups in SQL server. This setting - /// can't be changed after you create the endpoint. - /// Gets the provisioning state of the - /// PublicIP resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public LoadBalancingRule(string protocol, int frontendPort, string id = default(string), SubResource frontendIPConfiguration = default(SubResource), SubResource backendAddressPool = default(SubResource), SubResource probe = default(SubResource), string loadDistribution = default(string), int? backendPort = default(int?), int? idleTimeoutInMinutes = default(int?), bool? enableFloatingIP = default(bool?), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - FrontendIPConfiguration = frontendIPConfiguration; - BackendAddressPool = backendAddressPool; - Probe = probe; - Protocol = protocol; - LoadDistribution = loadDistribution; - FrontendPort = frontendPort; - BackendPort = backendPort; - IdleTimeoutInMinutes = idleTimeoutInMinutes; - EnableFloatingIP = enableFloatingIP; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a reference to frontend IP addresses. - /// - [JsonProperty(PropertyName = "properties.frontendIPConfiguration")] - public SubResource FrontendIPConfiguration { get; set; } - - /// - /// Gets or sets a reference to a pool of DIPs. Inbound traffic is - /// randomly load balanced across IPs in the backend IPs. - /// - [JsonProperty(PropertyName = "properties.backendAddressPool")] - public SubResource BackendAddressPool { get; set; } - - /// - /// Gets or sets the reference of the load balancer probe used by the - /// load balancing rule. - /// - [JsonProperty(PropertyName = "properties.probe")] - public SubResource Probe { get; set; } - - /// - /// Gets or sets the transport protocol for the external endpoint. - /// Possible values are 'Udp' or 'Tcp'. Possible values include: 'Udp', - /// 'Tcp' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets the load distribution policy for this rule. Possible - /// values are 'Default', 'SourceIP', and 'SourceIPProtocol'. Possible - /// values include: 'Default', 'SourceIP', 'SourceIPProtocol' - /// - [JsonProperty(PropertyName = "properties.loadDistribution")] - public string LoadDistribution { get; set; } - - /// - /// Gets or sets the port for the external endpoint. Port numbers for - /// each Rule must be unique within the Load Balancer. Acceptable - /// values are between 1 and 65534. - /// - [JsonProperty(PropertyName = "properties.frontendPort")] - public int FrontendPort { get; set; } - - /// - /// Gets or sets the port used for internal connections on the - /// endpoint. Acceptable values are between 1 and 65535. - /// - [JsonProperty(PropertyName = "properties.backendPort")] - public int? BackendPort { get; set; } - - /// - /// Gets or sets the timeout for the TCP idle connection. The value can - /// be set between 4 and 30 minutes. The default value is 4 minutes. - /// This element is only used when the protocol is set to TCP. - /// - [JsonProperty(PropertyName = "properties.idleTimeoutInMinutes")] - public int? IdleTimeoutInMinutes { get; set; } - - /// - /// Gets or sets configures a virtual machine's endpoint for the - /// floating IP capability required to configure a SQL AlwaysOn - /// Availability Group. This setting is required when using the SQL - /// AlwaysOn Availability Groups in SQL server. This setting can't be - /// changed after you create the endpoint. - /// - [JsonProperty(PropertyName = "properties.enableFloatingIP")] - public bool? EnableFloatingIP { get; set; } - - /// - /// Gets the provisioning state of the PublicIP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Protocol == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Protocol"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/LoadDistribution.cs b/Samples/test/end-to-end/network/Client/Models/LoadDistribution.cs index bf37256ea..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/LoadDistribution.cs +++ b/Samples/test/end-to-end/network/Client/Models/LoadDistribution.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for LoadDistribution. - /// - public static class LoadDistribution - { - public const string Default = "Default"; - public const string SourceIP = "SourceIP"; - public const string SourceIPProtocol = "SourceIPProtocol"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/LocalNetworkGateway.cs b/Samples/test/end-to-end/network/Client/Models/LocalNetworkGateway.cs index 5665aa656..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/LocalNetworkGateway.cs +++ b/Samples/test/end-to-end/network/Client/Models/LocalNetworkGateway.cs @@ -1,108 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A common class for general resource information - /// - [JsonTransformation] - public partial class LocalNetworkGateway : Resource - { - /// - /// Initializes a new instance of the LocalNetworkGateway class. - /// - public LocalNetworkGateway() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the LocalNetworkGateway class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// Local network site address - /// space. - /// IP address of local network - /// gateway. - /// Local network gateway's BGP speaker - /// settings. - /// The resource GUID property of the - /// LocalNetworkGateway resource. - /// The provisioning state of the - /// LocalNetworkGateway resource. Possible values are: 'Updating', - /// 'Deleting', and 'Failed'. - /// A unique read-only string that changes whenever - /// the resource is updated. - public LocalNetworkGateway(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), AddressSpace localNetworkAddressSpace = default(AddressSpace), string gatewayIpAddress = default(string), BgpSettings bgpSettings = default(BgpSettings), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - LocalNetworkAddressSpace = localNetworkAddressSpace; - GatewayIpAddress = gatewayIpAddress; - BgpSettings = bgpSettings; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets local network site address space. - /// - [JsonProperty(PropertyName = "properties.localNetworkAddressSpace")] - public AddressSpace LocalNetworkAddressSpace { get; set; } - - /// - /// Gets or sets IP address of local network gateway. - /// - [JsonProperty(PropertyName = "properties.gatewayIpAddress")] - public string GatewayIpAddress { get; set; } - - /// - /// Gets or sets local network gateway's BGP speaker settings. - /// - [JsonProperty(PropertyName = "properties.bgpSettings")] - public BgpSettings BgpSettings { get; set; } - - /// - /// Gets or sets the resource GUID property of the LocalNetworkGateway - /// resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets the provisioning state of the LocalNetworkGateway resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NetworkInterface.cs b/Samples/test/end-to-end/network/Client/Models/NetworkInterface.cs index 750e7e62c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NetworkInterface.cs +++ b/Samples/test/end-to-end/network/Client/Models/NetworkInterface.cs @@ -1,156 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A network interface in a resource group. - /// - [JsonTransformation] - public partial class NetworkInterface : Resource - { - /// - /// Initializes a new instance of the NetworkInterface class. - /// - public NetworkInterface() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NetworkInterface class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// The reference of a virtual - /// machine. - /// The reference of the - /// NetworkSecurityGroup resource. - /// A list of IPConfigurations of the - /// network interface. - /// The DNS settings in network - /// interface. - /// The MAC address of the network - /// interface. - /// Gets whether this is a primary network - /// interface on a virtual machine. - /// If the network interface - /// is accelerated networking enabled. - /// Indicates whether IP forwarding is - /// enabled on this network interface. - /// The resource GUID property of the - /// network interface resource. - /// The provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// A unique read-only string that changes whenever - /// the resource is updated. - public NetworkInterface(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), SubResource virtualMachine = default(SubResource), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), IList ipConfigurations = default(IList), NetworkInterfaceDnsSettings dnsSettings = default(NetworkInterfaceDnsSettings), string macAddress = default(string), bool? primary = default(bool?), bool? enableAcceleratedNetworking = default(bool?), bool? enableIPForwarding = default(bool?), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - VirtualMachine = virtualMachine; - NetworkSecurityGroup = networkSecurityGroup; - IpConfigurations = ipConfigurations; - DnsSettings = dnsSettings; - MacAddress = macAddress; - Primary = primary; - EnableAcceleratedNetworking = enableAcceleratedNetworking; - EnableIPForwarding = enableIPForwarding; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the reference of a virtual machine. - /// - [JsonProperty(PropertyName = "properties.virtualMachine")] - public SubResource VirtualMachine { get; set; } - - /// - /// Gets or sets the reference of the NetworkSecurityGroup resource. - /// - [JsonProperty(PropertyName = "properties.networkSecurityGroup")] - public NetworkSecurityGroup NetworkSecurityGroup { get; set; } - - /// - /// Gets or sets a list of IPConfigurations of the network interface. - /// - [JsonProperty(PropertyName = "properties.ipConfigurations")] - public IList IpConfigurations { get; set; } - - /// - /// Gets or sets the DNS settings in network interface. - /// - [JsonProperty(PropertyName = "properties.dnsSettings")] - public NetworkInterfaceDnsSettings DnsSettings { get; set; } - - /// - /// Gets or sets the MAC address of the network interface. - /// - [JsonProperty(PropertyName = "properties.macAddress")] - public string MacAddress { get; set; } - - /// - /// Gets whether this is a primary network interface on a virtual - /// machine. - /// - [JsonProperty(PropertyName = "properties.primary")] - public bool? Primary { get; set; } - - /// - /// Gets or sets if the network interface is accelerated networking - /// enabled. - /// - [JsonProperty(PropertyName = "properties.enableAcceleratedNetworking")] - public bool? EnableAcceleratedNetworking { get; set; } - - /// - /// Gets or sets indicates whether IP forwarding is enabled on this - /// network interface. - /// - [JsonProperty(PropertyName = "properties.enableIPForwarding")] - public bool? EnableIPForwarding { get; set; } - - /// - /// Gets or sets the resource GUID property of the network interface - /// resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets or sets the provisioning state of the public IP resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceAssociation.cs b/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceAssociation.cs index b1545fb44..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceAssociation.cs +++ b/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceAssociation.cs @@ -1,60 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Network interface and its custom security rules. - /// - public partial class NetworkInterfaceAssociation - { - /// - /// Initializes a new instance of the NetworkInterfaceAssociation - /// class. - /// - public NetworkInterfaceAssociation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NetworkInterfaceAssociation - /// class. - /// - /// Network interface ID. - /// Collection of custom security - /// rules. - public NetworkInterfaceAssociation(string id = default(string), IList securityRules = default(IList)) - { - Id = id; - SecurityRules = securityRules; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets network interface ID. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets or sets collection of custom security rules. - /// - [JsonProperty(PropertyName = "securityRules")] - public IList SecurityRules { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceDnsSettings.cs b/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceDnsSettings.cs index 429cb1143..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceDnsSettings.cs +++ b/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceDnsSettings.cs @@ -1,108 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// DNS settings of a network interface. - /// - public partial class NetworkInterfaceDnsSettings - { - /// - /// Initializes a new instance of the NetworkInterfaceDnsSettings - /// class. - /// - public NetworkInterfaceDnsSettings() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NetworkInterfaceDnsSettings - /// class. - /// - /// List of DNS servers IP addresses. Use - /// 'AzureProvidedDNS' to switch to azure provided DNS resolution. - /// 'AzureProvidedDNS' value cannot be combined with other IPs, it must - /// be the only value in dnsServers collection. - /// If the VM that uses this NIC is - /// part of an Availability Set, then this list will have the union of - /// all DNS servers from all NICs that are part of the Availability - /// Set. This property is what is configured on each of those - /// VMs. - /// Relative DNS name for this NIC - /// used for internal communications between VMs in the same virtual - /// network. - /// Fully qualified DNS name supporting - /// internal communications between VMs in the same virtual - /// network. - /// Even if internalDnsNameLabel - /// is not specified, a DNS entry is created for the primary NIC of the - /// VM. This DNS name can be constructed by concatenating the VM name - /// with the value of internalDomainNameSuffix. - public NetworkInterfaceDnsSettings(IList dnsServers = default(IList), IList appliedDnsServers = default(IList), string internalDnsNameLabel = default(string), string internalFqdn = default(string), string internalDomainNameSuffix = default(string)) - { - DnsServers = dnsServers; - AppliedDnsServers = appliedDnsServers; - InternalDnsNameLabel = internalDnsNameLabel; - InternalFqdn = internalFqdn; - InternalDomainNameSuffix = internalDomainNameSuffix; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets list of DNS servers IP addresses. Use - /// 'AzureProvidedDNS' to switch to azure provided DNS resolution. - /// 'AzureProvidedDNS' value cannot be combined with other IPs, it must - /// be the only value in dnsServers collection. - /// - [JsonProperty(PropertyName = "dnsServers")] - public IList DnsServers { get; set; } - - /// - /// Gets or sets if the VM that uses this NIC is part of an - /// Availability Set, then this list will have the union of all DNS - /// servers from all NICs that are part of the Availability Set. This - /// property is what is configured on each of those VMs. - /// - [JsonProperty(PropertyName = "appliedDnsServers")] - public IList AppliedDnsServers { get; set; } - - /// - /// Gets or sets relative DNS name for this NIC used for internal - /// communications between VMs in the same virtual network. - /// - [JsonProperty(PropertyName = "internalDnsNameLabel")] - public string InternalDnsNameLabel { get; set; } - - /// - /// Gets or sets fully qualified DNS name supporting internal - /// communications between VMs in the same virtual network. - /// - [JsonProperty(PropertyName = "internalFqdn")] - public string InternalFqdn { get; set; } - - /// - /// Gets or sets even if internalDnsNameLabel is not specified, a DNS - /// entry is created for the primary NIC of the VM. This DNS name can - /// be constructed by concatenating the VM name with the value of - /// internalDomainNameSuffix. - /// - [JsonProperty(PropertyName = "internalDomainNameSuffix")] - public string InternalDomainNameSuffix { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceIPConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceIPConfiguration.cs index 7d6191dae..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceIPConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/NetworkInterfaceIPConfiguration.cs @@ -1,159 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// IPConfiguration in a network interface. - /// - [JsonTransformation] - public partial class NetworkInterfaceIPConfiguration : SubResource - { - /// - /// Initializes a new instance of the NetworkInterfaceIPConfiguration - /// class. - /// - public NetworkInterfaceIPConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NetworkInterfaceIPConfiguration - /// class. - /// - /// Resource ID. - /// The reference - /// of ApplicationGatewayBackendAddressPool resource. - /// The reference of - /// LoadBalancerBackendAddressPool resource. - /// A list of references of - /// LoadBalancerInboundNatRules. - /// Defines how a private IP - /// address is assigned. Possible values are: 'Static' and 'Dynamic'. - /// Possible values include: 'Static', 'Dynamic' - /// Available from Api-Version - /// 2016-03-30 onwards, it represents whether the specific - /// ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - /// Possible values are: 'IPv4' and 'IPv6'. Possible values include: - /// 'IPv4', 'IPv6' - /// Gets whether this is a primary customer - /// address on the network interface. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public NetworkInterfaceIPConfiguration(string id = default(string), IList applicationGatewayBackendAddressPools = default(IList), IList loadBalancerBackendAddressPools = default(IList), IList loadBalancerInboundNatRules = default(IList), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), string privateIPAddressVersion = default(string), Subnet subnet = default(Subnet), bool? primary = default(bool?), PublicIPAddress publicIPAddress = default(PublicIPAddress), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - ApplicationGatewayBackendAddressPools = applicationGatewayBackendAddressPools; - LoadBalancerBackendAddressPools = loadBalancerBackendAddressPools; - LoadBalancerInboundNatRules = loadBalancerInboundNatRules; - PrivateIPAddress = privateIPAddress; - PrivateIPAllocationMethod = privateIPAllocationMethod; - PrivateIPAddressVersion = privateIPAddressVersion; - Subnet = subnet; - Primary = primary; - PublicIPAddress = publicIPAddress; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the reference of ApplicationGatewayBackendAddressPool - /// resource. - /// - [JsonProperty(PropertyName = "properties.applicationGatewayBackendAddressPools")] - public IList ApplicationGatewayBackendAddressPools { get; set; } - - /// - /// Gets or sets the reference of LoadBalancerBackendAddressPool - /// resource. - /// - [JsonProperty(PropertyName = "properties.loadBalancerBackendAddressPools")] - public IList LoadBalancerBackendAddressPools { get; set; } - - /// - /// Gets or sets a list of references of LoadBalancerInboundNatRules. - /// - [JsonProperty(PropertyName = "properties.loadBalancerInboundNatRules")] - public IList LoadBalancerInboundNatRules { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.privateIPAddress")] - public string PrivateIPAddress { get; set; } - - /// - /// Gets or sets defines how a private IP address is assigned. Possible - /// values are: 'Static' and 'Dynamic'. Possible values include: - /// 'Static', 'Dynamic' - /// - [JsonProperty(PropertyName = "properties.privateIPAllocationMethod")] - public string PrivateIPAllocationMethod { get; set; } - - /// - /// Gets or sets available from Api-Version 2016-03-30 onwards, it - /// represents whether the specific ipconfiguration is IPv4 or IPv6. - /// Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. - /// Possible values include: 'IPv4', 'IPv6' - /// - [JsonProperty(PropertyName = "properties.privateIPAddressVersion")] - public string PrivateIPAddressVersion { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.subnet")] - public Subnet Subnet { get; set; } - - /// - /// Gets whether this is a primary customer address on the network - /// interface. - /// - [JsonProperty(PropertyName = "properties.primary")] - public bool? Primary { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.publicIPAddress")] - public PublicIPAddress PublicIPAddress { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NetworkOperationStatus.cs b/Samples/test/end-to-end/network/Client/Models/NetworkOperationStatus.cs index ffc29d744..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NetworkOperationStatus.cs +++ b/Samples/test/end-to-end/network/Client/Models/NetworkOperationStatus.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for NetworkOperationStatus. - /// - public static class NetworkOperationStatus - { - public const string InProgress = "InProgress"; - public const string Succeeded = "Succeeded"; - public const string Failed = "Failed"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NetworkSecurityGroup.cs b/Samples/test/end-to-end/network/Client/Models/NetworkSecurityGroup.cs index 0314ebb30..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NetworkSecurityGroup.cs +++ b/Samples/test/end-to-end/network/Client/Models/NetworkSecurityGroup.cs @@ -1,118 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// NetworkSecurityGroup resource. - /// - [JsonTransformation] - public partial class NetworkSecurityGroup : Resource - { - /// - /// Initializes a new instance of the NetworkSecurityGroup class. - /// - public NetworkSecurityGroup() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NetworkSecurityGroup class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// A collection of security rules of the - /// network security group. - /// The default security rules of - /// network security group. - /// A collection of references to - /// network interfaces. - /// A collection of references to - /// subnets. - /// The resource GUID property of the - /// network security group resource. - /// The provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// A unique read-only string that changes whenever - /// the resource is updated. - public NetworkSecurityGroup(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IList securityRules = default(IList), IList defaultSecurityRules = default(IList), IList networkInterfaces = default(IList), IList subnets = default(IList), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - SecurityRules = securityRules; - DefaultSecurityRules = defaultSecurityRules; - NetworkInterfaces = networkInterfaces; - Subnets = subnets; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a collection of security rules of the network security - /// group. - /// - [JsonProperty(PropertyName = "properties.securityRules")] - public IList SecurityRules { get; set; } - - /// - /// Gets or sets the default security rules of network security group. - /// - [JsonProperty(PropertyName = "properties.defaultSecurityRules")] - public IList DefaultSecurityRules { get; set; } - - /// - /// Gets a collection of references to network interfaces. - /// - [JsonProperty(PropertyName = "properties.networkInterfaces")] - public IList NetworkInterfaces { get; private set; } - - /// - /// Gets a collection of references to subnets. - /// - [JsonProperty(PropertyName = "properties.subnets")] - public IList Subnets { get; private set; } - - /// - /// Gets or sets the resource GUID property of the network security - /// group resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets or sets the provisioning state of the public IP resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NetworkWatcher.cs b/Samples/test/end-to-end/network/Client/Models/NetworkWatcher.cs index 22fb6294c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NetworkWatcher.cs +++ b/Samples/test/end-to-end/network/Client/Models/NetworkWatcher.cs @@ -1,71 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Network watcher in a resource group. - /// - [JsonTransformation] - public partial class NetworkWatcher : Resource - { - /// - /// Initializes a new instance of the NetworkWatcher class. - /// - public NetworkWatcher() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NetworkWatcher class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// A unique read-only string that changes whenever - /// the resource is updated. - /// The provisioning state of the - /// resource. Possible values include: 'Succeeded', 'Updating', - /// 'Deleting', 'Failed' - public NetworkWatcher(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string etag = default(string), string provisioningState = default(string)) - : base(id, name, type, location, tags) - { - Etag = etag; - ProvisioningState = provisioningState; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Gets the provisioning state of the resource. Possible values - /// include: 'Succeeded', 'Updating', 'Deleting', 'Failed' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NextHopParameters.cs b/Samples/test/end-to-end/network/Client/Models/NextHopParameters.cs index 85428711f..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NextHopParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/NextHopParameters.cs @@ -1,101 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define the source and destination endpoint. - /// - public partial class NextHopParameters - { - /// - /// Initializes a new instance of the NextHopParameters class. - /// - public NextHopParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NextHopParameters class. - /// - /// The resource identifier of the - /// target resource against which the action is to be - /// performed. - /// The source IP address. - /// The destination IP - /// address. - /// The NIC ID. (If VM has multiple - /// NICs and IP forwarding is enabled on any of the nics, then this - /// parameter must be specified. Otherwise optional). - public NextHopParameters(string targetResourceId, string sourceIPAddress, string destinationIPAddress, string targetNicResourceId = default(string)) - { - TargetResourceId = targetResourceId; - SourceIPAddress = sourceIPAddress; - DestinationIPAddress = destinationIPAddress; - TargetNicResourceId = targetNicResourceId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the resource identifier of the target resource against - /// which the action is to be performed. - /// - [JsonProperty(PropertyName = "targetResourceId")] - public string TargetResourceId { get; set; } - - /// - /// Gets or sets the source IP address. - /// - [JsonProperty(PropertyName = "sourceIPAddress")] - public string SourceIPAddress { get; set; } - - /// - /// Gets or sets the destination IP address. - /// - [JsonProperty(PropertyName = "destinationIPAddress")] - public string DestinationIPAddress { get; set; } - - /// - /// Gets or sets the NIC ID. (If VM has multiple NICs and IP forwarding - /// is enabled on any of the nics, then this parameter must be - /// specified. Otherwise optional). - /// - [JsonProperty(PropertyName = "targetNicResourceId")] - public string TargetNicResourceId { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceId"); - } - if (SourceIPAddress == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SourceIPAddress"); - } - if (DestinationIPAddress == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "DestinationIPAddress"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NextHopResult.cs b/Samples/test/end-to-end/network/Client/Models/NextHopResult.cs index f128c4639..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NextHopResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/NextHopResult.cs @@ -1,73 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The information about next hop from the specified VM. - /// - public partial class NextHopResult - { - /// - /// Initializes a new instance of the NextHopResult class. - /// - public NextHopResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the NextHopResult class. - /// - /// Next hop type. Possible values include: - /// 'Internet', 'VirtualAppliance', 'VirtualNetworkGateway', - /// 'VnetLocal', 'HyperNetGateway', 'None' - /// Next hop IP Address - /// The resource identifier for the route - /// table associated with the route being returned. If the route being - /// returned does not correspond to any user created routes then this - /// field will be the string 'System Route'. - public NextHopResult(string nextHopType = default(string), string nextHopIpAddress = default(string), string routeTableId = default(string)) - { - NextHopType = nextHopType; - NextHopIpAddress = nextHopIpAddress; - RouteTableId = routeTableId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets next hop type. Possible values include: 'Internet', - /// 'VirtualAppliance', 'VirtualNetworkGateway', 'VnetLocal', - /// 'HyperNetGateway', 'None' - /// - [JsonProperty(PropertyName = "nextHopType")] - public string NextHopType { get; set; } - - /// - /// Gets or sets next hop IP Address - /// - [JsonProperty(PropertyName = "nextHopIpAddress")] - public string NextHopIpAddress { get; set; } - - /// - /// Gets or sets the resource identifier for the route table associated - /// with the route being returned. If the route being returned does not - /// correspond to any user created routes then this field will be the - /// string 'System Route'. - /// - [JsonProperty(PropertyName = "routeTableId")] - public string RouteTableId { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/NextHopType.cs b/Samples/test/end-to-end/network/Client/Models/NextHopType.cs index 501465e90..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/NextHopType.cs +++ b/Samples/test/end-to-end/network/Client/Models/NextHopType.cs @@ -1,22 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for NextHopType. - /// - public static class NextHopType - { - public const string Internet = "Internet"; - public const string VirtualAppliance = "VirtualAppliance"; - public const string VirtualNetworkGateway = "VirtualNetworkGateway"; - public const string VnetLocal = "VnetLocal"; - public const string HyperNetGateway = "HyperNetGateway"; - public const string None = "None"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/OutboundNatRule.cs b/Samples/test/end-to-end/network/Client/Models/OutboundNatRule.cs index 20c5d0d2f..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/OutboundNatRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/OutboundNatRule.cs @@ -1,120 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Outbound NAT pool of the load balancer. - /// - [JsonTransformation] - public partial class OutboundNatRule : SubResource - { - /// - /// Initializes a new instance of the OutboundNatRule class. - /// - public OutboundNatRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the OutboundNatRule class. - /// - /// A reference to a pool of DIPs. - /// Outbound traffic is randomly load balanced across IPs in the - /// backend IPs. - /// Resource ID. - /// The number of outbound ports - /// to be used for NAT. - /// The Frontend IP addresses of - /// the load balancer. - /// Gets the provisioning state of the - /// PublicIP resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public OutboundNatRule(SubResource backendAddressPool, string id = default(string), int? allocatedOutboundPorts = default(int?), IList frontendIPConfigurations = default(IList), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - AllocatedOutboundPorts = allocatedOutboundPorts; - FrontendIPConfigurations = frontendIPConfigurations; - BackendAddressPool = backendAddressPool; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the number of outbound ports to be used for NAT. - /// - [JsonProperty(PropertyName = "properties.allocatedOutboundPorts")] - public int? AllocatedOutboundPorts { get; set; } - - /// - /// Gets or sets the Frontend IP addresses of the load balancer. - /// - [JsonProperty(PropertyName = "properties.frontendIPConfigurations")] - public IList FrontendIPConfigurations { get; set; } - - /// - /// Gets or sets a reference to a pool of DIPs. Outbound traffic is - /// randomly load balanced across IPs in the backend IPs. - /// - [JsonProperty(PropertyName = "properties.backendAddressPool")] - public SubResource BackendAddressPool { get; set; } - - /// - /// Gets the provisioning state of the PublicIP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (BackendAddressPool == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "BackendAddressPool"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PacketCapture.cs b/Samples/test/end-to-end/network/Client/Models/PacketCapture.cs index 5b6d02424..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PacketCapture.cs +++ b/Samples/test/end-to-end/network/Client/Models/PacketCapture.cs @@ -1,111 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Parameters that define the create packet capture operation. - /// - [JsonTransformation] - public partial class PacketCapture - { - /// - /// Initializes a new instance of the PacketCapture class. - /// - public PacketCapture() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PacketCapture class. - /// - /// The ID of the targeted resource, only VM is - /// currently supported. - /// Number of bytes captured per - /// packet, the remaining bytes are truncated. - /// Maximum size of the capture - /// output. - /// Maximum duration of the capture - /// session in seconds. - public PacketCapture(string target, PacketCaptureStorageLocation storageLocation, int? bytesToCapturePerPacket = default(int?), int? totalBytesPerSession = default(int?), int? timeLimitInSeconds = default(int?), IList filters = default(IList)) - { - Target = target; - BytesToCapturePerPacket = bytesToCapturePerPacket; - TotalBytesPerSession = totalBytesPerSession; - TimeLimitInSeconds = timeLimitInSeconds; - StorageLocation = storageLocation; - Filters = filters; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the ID of the targeted resource, only VM is currently - /// supported. - /// - [JsonProperty(PropertyName = "properties.target")] - public string Target { get; set; } - - /// - /// Gets or sets number of bytes captured per packet, the remaining - /// bytes are truncated. - /// - [JsonProperty(PropertyName = "properties.bytesToCapturePerPacket")] - public int? BytesToCapturePerPacket { get; set; } - - /// - /// Gets or sets maximum size of the capture output. - /// - [JsonProperty(PropertyName = "properties.totalBytesPerSession")] - public int? TotalBytesPerSession { get; set; } - - /// - /// Gets or sets maximum duration of the capture session in seconds. - /// - [JsonProperty(PropertyName = "properties.timeLimitInSeconds")] - public int? TimeLimitInSeconds { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.storageLocation")] - public PacketCaptureStorageLocation StorageLocation { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.filters")] - public IList Filters { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Target == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Target"); - } - if (StorageLocation == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "StorageLocation"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PacketCaptureFilter.cs b/Samples/test/end-to-end/network/Client/Models/PacketCaptureFilter.cs index 624ab6102..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PacketCaptureFilter.cs +++ b/Samples/test/end-to-end/network/Client/Models/PacketCaptureFilter.cs @@ -1,114 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Filter that is applied to packet capture request. Multiple filters can - /// be applied. - /// - public partial class PacketCaptureFilter - { - /// - /// Initializes a new instance of the PacketCaptureFilter class. - /// - public PacketCaptureFilter() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PacketCaptureFilter class. - /// - /// Protocol to be filtered on. Possible values - /// include: 'TCP', 'UDP', 'Any' - /// Local IP Address to be filtered on. - /// Notation: "127.0.0.1" for single address entry. - /// "127.0.0.1-127.0.0.255" for range. "127.0.0.1;127.0.0.5"? for - /// multiple entries. Multiple ranges not currently supported. Mixing - /// ranges with multiple entries not currently supported. Default = - /// null. - /// Local IP Address to be filtered on. - /// Notation: "127.0.0.1" for single address entry. - /// "127.0.0.1-127.0.0.255" for range. "127.0.0.1;127.0.0.5;" for - /// multiple entries. Multiple ranges not currently supported. Mixing - /// ranges with multiple entries not currently supported. Default = - /// null. - /// Local port to be filtered on. Notation: - /// "80" for single port entry."80-85" for range. "80;443;" for - /// multiple entries. Multiple ranges not currently supported. Mixing - /// ranges with multiple entries not currently supported. Default = - /// null. - /// Remote port to be filtered on. Notation: - /// "80" for single port entry."80-85" for range. "80;443;" for - /// multiple entries. Multiple ranges not currently supported. Mixing - /// ranges with multiple entries not currently supported. Default = - /// null. - public PacketCaptureFilter(string protocol = default(string), string localIPAddress = default(string), string remoteIPAddress = default(string), string localPort = default(string), string remotePort = default(string)) - { - Protocol = protocol; - LocalIPAddress = localIPAddress; - RemoteIPAddress = remoteIPAddress; - LocalPort = localPort; - RemotePort = remotePort; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets protocol to be filtered on. Possible values include: - /// 'TCP', 'UDP', 'Any' - /// - [JsonProperty(PropertyName = "protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets local IP Address to be filtered on. Notation: - /// "127.0.0.1" for single address entry. "127.0.0.1-127.0.0.255" for - /// range. "127.0.0.1;127.0.0.5"? for multiple entries. Multiple ranges - /// not currently supported. Mixing ranges with multiple entries not - /// currently supported. Default = null. - /// - [JsonProperty(PropertyName = "localIPAddress")] - public string LocalIPAddress { get; set; } - - /// - /// Gets or sets local IP Address to be filtered on. Notation: - /// "127.0.0.1" for single address entry. "127.0.0.1-127.0.0.255" for - /// range. "127.0.0.1;127.0.0.5;" for multiple entries. Multiple ranges - /// not currently supported. Mixing ranges with multiple entries not - /// currently supported. Default = null. - /// - [JsonProperty(PropertyName = "remoteIPAddress")] - public string RemoteIPAddress { get; set; } - - /// - /// Gets or sets local port to be filtered on. Notation: "80" for - /// single port entry."80-85" for range. "80;443;" for multiple - /// entries. Multiple ranges not currently supported. Mixing ranges - /// with multiple entries not currently supported. Default = null. - /// - [JsonProperty(PropertyName = "localPort")] - public string LocalPort { get; set; } - - /// - /// Gets or sets remote port to be filtered on. Notation: "80" for - /// single port entry."80-85" for range. "80;443;" for multiple - /// entries. Multiple ranges not currently supported. Mixing ranges - /// with multiple entries not currently supported. Default = null. - /// - [JsonProperty(PropertyName = "remotePort")] - public string RemotePort { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PacketCaptureParameters.cs b/Samples/test/end-to-end/network/Client/Models/PacketCaptureParameters.cs index 2529a333d..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PacketCaptureParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/PacketCaptureParameters.cs @@ -1,109 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Parameters that define the create packet capture operation. - /// - public partial class PacketCaptureParameters - { - /// - /// Initializes a new instance of the PacketCaptureParameters class. - /// - public PacketCaptureParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PacketCaptureParameters class. - /// - /// The ID of the targeted resource, only VM is - /// currently supported. - /// Number of bytes captured per - /// packet, the remaining bytes are truncated. - /// Maximum size of the capture - /// output. - /// Maximum duration of the capture - /// session in seconds. - public PacketCaptureParameters(string target, PacketCaptureStorageLocation storageLocation, int? bytesToCapturePerPacket = default(int?), int? totalBytesPerSession = default(int?), int? timeLimitInSeconds = default(int?), IList filters = default(IList)) - { - Target = target; - BytesToCapturePerPacket = bytesToCapturePerPacket; - TotalBytesPerSession = totalBytesPerSession; - TimeLimitInSeconds = timeLimitInSeconds; - StorageLocation = storageLocation; - Filters = filters; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the ID of the targeted resource, only VM is currently - /// supported. - /// - [JsonProperty(PropertyName = "target")] - public string Target { get; set; } - - /// - /// Gets or sets number of bytes captured per packet, the remaining - /// bytes are truncated. - /// - [JsonProperty(PropertyName = "bytesToCapturePerPacket")] - public int? BytesToCapturePerPacket { get; set; } - - /// - /// Gets or sets maximum size of the capture output. - /// - [JsonProperty(PropertyName = "totalBytesPerSession")] - public int? TotalBytesPerSession { get; set; } - - /// - /// Gets or sets maximum duration of the capture session in seconds. - /// - [JsonProperty(PropertyName = "timeLimitInSeconds")] - public int? TimeLimitInSeconds { get; set; } - - /// - /// - [JsonProperty(PropertyName = "storageLocation")] - public PacketCaptureStorageLocation StorageLocation { get; set; } - - /// - /// - [JsonProperty(PropertyName = "filters")] - public IList Filters { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Target == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Target"); - } - if (StorageLocation == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "StorageLocation"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PacketCaptureQueryStatusResult.cs b/Samples/test/end-to-end/network/Client/Models/PacketCaptureQueryStatusResult.cs index ff050bc92..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PacketCaptureQueryStatusResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/PacketCaptureQueryStatusResult.cs @@ -1,99 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Status of packet capture session. - /// - public partial class PacketCaptureQueryStatusResult - { - /// - /// Initializes a new instance of the PacketCaptureQueryStatusResult - /// class. - /// - public PacketCaptureQueryStatusResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PacketCaptureQueryStatusResult - /// class. - /// - /// The name of the packet capture resource. - /// The ID of the packet capture resource. - /// The start time of the packet capture - /// session. - /// The status of the packet capture - /// session. Possible values include: 'NotStarted', 'Running', - /// 'Stopped', 'Error', 'Unknown' - /// The reason the current packet capture - /// session was stopped. - /// List of errors of packet capture - /// session. - public PacketCaptureQueryStatusResult(string name = default(string), string id = default(string), System.DateTime? captureStartTime = default(System.DateTime?), string packetCaptureStatus = default(string), string stopReason = default(string), IList packetCaptureError = default(IList)) - { - Name = name; - Id = id; - CaptureStartTime = captureStartTime; - PacketCaptureStatus = packetCaptureStatus; - StopReason = stopReason; - PacketCaptureError = packetCaptureError; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the packet capture resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the ID of the packet capture resource. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - /// - /// Gets or sets the start time of the packet capture session. - /// - [JsonProperty(PropertyName = "captureStartTime")] - public System.DateTime? CaptureStartTime { get; set; } - - /// - /// Gets or sets the status of the packet capture session. Possible - /// values include: 'NotStarted', 'Running', 'Stopped', 'Error', - /// 'Unknown' - /// - [JsonProperty(PropertyName = "packetCaptureStatus")] - public string PacketCaptureStatus { get; set; } - - /// - /// Gets or sets the reason the current packet capture session was - /// stopped. - /// - [JsonProperty(PropertyName = "stopReason")] - public string StopReason { get; set; } - - /// - /// Gets or sets list of errors of packet capture session. - /// - [JsonProperty(PropertyName = "packetCaptureError")] - public IList PacketCaptureError { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PacketCaptureResult.cs b/Samples/test/end-to-end/network/Client/Models/PacketCaptureResult.cs index 0f4b52ba3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PacketCaptureResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/PacketCaptureResult.cs @@ -1,145 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Information about packet capture session. - /// - [JsonTransformation] - public partial class PacketCaptureResult - { - /// - /// Initializes a new instance of the PacketCaptureResult class. - /// - public PacketCaptureResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PacketCaptureResult class. - /// - /// The ID of the targeted resource, only VM is - /// currently supported. - /// Name of the packet capture session. - /// ID of the packet capture operation. - /// Number of bytes captured per - /// packet, the remaining bytes are truncated. - /// Maximum size of the capture - /// output. - /// Maximum duration of the capture - /// session in seconds. - /// The provisioning state of the - /// packet capture session. Possible values include: 'Succeeded', - /// 'Updating', 'Deleting', 'Failed' - public PacketCaptureResult(string target, PacketCaptureStorageLocation storageLocation, string name = default(string), string id = default(string), string etag = default(string), int? bytesToCapturePerPacket = default(int?), int? totalBytesPerSession = default(int?), int? timeLimitInSeconds = default(int?), IList filters = default(IList), string provisioningState = default(string)) - { - Name = name; - Id = id; - Etag = etag; - Target = target; - BytesToCapturePerPacket = bytesToCapturePerPacket; - TotalBytesPerSession = totalBytesPerSession; - TimeLimitInSeconds = timeLimitInSeconds; - StorageLocation = storageLocation; - Filters = filters; - ProvisioningState = provisioningState; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets name of the packet capture session. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets ID of the packet capture operation. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Gets or sets the ID of the targeted resource, only VM is currently - /// supported. - /// - [JsonProperty(PropertyName = "properties.target")] - public string Target { get; set; } - - /// - /// Gets or sets number of bytes captured per packet, the remaining - /// bytes are truncated. - /// - [JsonProperty(PropertyName = "properties.bytesToCapturePerPacket")] - public int? BytesToCapturePerPacket { get; set; } - - /// - /// Gets or sets maximum size of the capture output. - /// - [JsonProperty(PropertyName = "properties.totalBytesPerSession")] - public int? TotalBytesPerSession { get; set; } - - /// - /// Gets or sets maximum duration of the capture session in seconds. - /// - [JsonProperty(PropertyName = "properties.timeLimitInSeconds")] - public int? TimeLimitInSeconds { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.storageLocation")] - public PacketCaptureStorageLocation StorageLocation { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.filters")] - public IList Filters { get; set; } - - /// - /// Gets or sets the provisioning state of the packet capture session. - /// Possible values include: 'Succeeded', 'Updating', 'Deleting', - /// 'Failed' - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Target == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Target"); - } - if (StorageLocation == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "StorageLocation"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PacketCaptureStorageLocation.cs b/Samples/test/end-to-end/network/Client/Models/PacketCaptureStorageLocation.cs index 843c8cdff..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PacketCaptureStorageLocation.cs +++ b/Samples/test/end-to-end/network/Client/Models/PacketCaptureStorageLocation.cs @@ -1,78 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes the storage location for a packet capture session. - /// - public partial class PacketCaptureStorageLocation - { - /// - /// Initializes a new instance of the PacketCaptureStorageLocation - /// class. - /// - public PacketCaptureStorageLocation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PacketCaptureStorageLocation - /// class. - /// - /// The ID of the storage account to save the - /// packet capture session. Required if no local file path is - /// provided. - /// The URI of the storage path to save the - /// packet capture. Must be a well-formed URI describing the location - /// to save the packet capture. - /// A valid local path on the targeting VM. Must - /// include the name of the capture file (*.cap). For linux virtual - /// machine it must start with /var/captures. Required if no storage ID - /// is provided, otherwise optional. - public PacketCaptureStorageLocation(string storageId = default(string), string storagePath = default(string), string filePath = default(string)) - { - StorageId = storageId; - StoragePath = storagePath; - FilePath = filePath; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the ID of the storage account to save the packet - /// capture session. Required if no local file path is provided. - /// - [JsonProperty(PropertyName = "storageId")] - public string StorageId { get; set; } - - /// - /// Gets or sets the URI of the storage path to save the packet - /// capture. Must be a well-formed URI describing the location to save - /// the packet capture. - /// - [JsonProperty(PropertyName = "storagePath")] - public string StoragePath { get; set; } - - /// - /// Gets or sets a valid local path on the targeting VM. Must include - /// the name of the capture file (*.cap). For linux virtual machine it - /// must start with /var/captures. Required if no storage ID is - /// provided, otherwise optional. - /// - [JsonProperty(PropertyName = "filePath")] - public string FilePath { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Page.cs b/Samples/test/end-to-end/network/Client/Models/Page.cs index b58dc073c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Page.cs +++ b/Samples/test/end-to-end/network/Client/Models/Page.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - - /// - /// Defines a page in Azure responses. - /// - /// Type of the page content items - [JsonObject] - public class Page : IPage - { - /// - /// Gets the link to the next page. - /// - [JsonProperty("nextLink")] - public string NextPageLink { get; private set; } - - [JsonProperty("value")] - private IList Items{ get; set; } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Page1.cs b/Samples/test/end-to-end/network/Client/Models/Page1.cs index 6defe6b43..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Page1.cs +++ b/Samples/test/end-to-end/network/Client/Models/Page1.cs @@ -1,49 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - - /// - /// Defines a page in Azure responses. - /// - /// Type of the page content items - [JsonObject] - public class Page1 : IPage - { - /// - /// Gets the link to the next page. - /// - [JsonProperty("")] - public string NextPageLink { get; private set; } - - [JsonProperty("value")] - private IList Items{ get; set; } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// A an enumerator that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PatchRouteFilter.cs b/Samples/test/end-to-end/network/Client/Models/PatchRouteFilter.cs index 48c6d66d3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PatchRouteFilter.cs +++ b/Samples/test/end-to-end/network/Client/Models/PatchRouteFilter.cs @@ -1,113 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Route Filter Resource. - /// - [JsonTransformation] - public partial class PatchRouteFilter : SubResource - { - /// - /// Initializes a new instance of the PatchRouteFilter class. - /// - public PatchRouteFilter() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PatchRouteFilter class. - /// - /// Resource ID. - /// Collection of RouteFilterRules contained within - /// a route filter. - /// A collection of references to express route - /// circuit peerings. - /// The provisioning state of the - /// resource. Possible values are: 'Updating', 'Deleting', 'Succeeded' - /// and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - /// Resource type. - /// Resource tags. - public PatchRouteFilter(string id = default(string), IList rules = default(IList), IList peerings = default(IList), string provisioningState = default(string), string name = default(string), string etag = default(string), string type = default(string), IDictionary tags = default(IDictionary)) - : base(id) - { - Rules = rules; - Peerings = peerings; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - Type = type; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets collection of RouteFilterRules contained within a - /// route filter. - /// - [JsonProperty(PropertyName = "properties.rules")] - public IList Rules { get; set; } - - /// - /// Gets a collection of references to express route circuit peerings. - /// - [JsonProperty(PropertyName = "properties.peerings")] - public IList Peerings { get; private set; } - - /// - /// Gets the provisioning state of the resource. Possible values are: - /// 'Updating', 'Deleting', 'Succeeded' and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets the name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - /// - /// Gets resource type. - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource tags. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PatchRouteFilterRule.cs b/Samples/test/end-to-end/network/Client/Models/PatchRouteFilterRule.cs index 469b375b9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PatchRouteFilterRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/PatchRouteFilterRule.cs @@ -1,136 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Route Filter Rule Resource - /// - [JsonTransformation] - public partial class PatchRouteFilterRule : SubResource - { - /// - /// Initializes a new instance of the PatchRouteFilterRule class. - /// - public PatchRouteFilterRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PatchRouteFilterRule class. - /// - /// The access type of the rule. Valid values are: - /// 'Allow', 'Deny'. Possible values include: 'Allow', 'Deny' - /// The collection for bgp community values - /// to filter on. e.g. ['12076:5010','12076:5020'] - /// Resource ID. - /// The provisioning state of the - /// resource. Possible values are: 'Updating', 'Deleting', 'Succeeded' - /// and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - /// Resource tags. - public PatchRouteFilterRule(string access, IList communities, string id = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string), IDictionary tags = default(IDictionary)) - : base(id) - { - Access = access; - Communities = communities; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - Tags = tags; - CustomInit(); - } - /// - /// Static constructor for PatchRouteFilterRule class. - /// - static PatchRouteFilterRule() - { - RouteFilterRuleType = "Community"; - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the access type of the rule. Valid values are: - /// 'Allow', 'Deny'. Possible values include: 'Allow', 'Deny' - /// - [JsonProperty(PropertyName = "properties.access")] - public string Access { get; set; } - - /// - /// Gets or sets the collection for bgp community values to filter on. - /// e.g. ['12076:5010','12076:5020'] - /// - [JsonProperty(PropertyName = "properties.communities")] - public IList Communities { get; set; } - - /// - /// Gets the provisioning state of the resource. Possible values are: - /// 'Updating', 'Deleting', 'Succeeded' and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets the name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - /// - /// Gets or sets resource tags. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// The rule type of the rule. Valid value is: 'Community' - /// - [JsonProperty(PropertyName = "properties.routeFilterRuleType")] - public static string RouteFilterRuleType { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Access == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Access"); - } - if (Communities == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Communities"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PcError.cs b/Samples/test/end-to-end/network/Client/Models/PcError.cs index f2e10841c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PcError.cs +++ b/Samples/test/end-to-end/network/Client/Models/PcError.cs @@ -1,21 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for PcError. - /// - public static class PcError - { - public const string InternalError = "InternalError"; - public const string AgentStopped = "AgentStopped"; - public const string CaptureFailed = "CaptureFailed"; - public const string LocalFileFailed = "LocalFileFailed"; - public const string StorageFailed = "StorageFailed"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PcProtocol.cs b/Samples/test/end-to-end/network/Client/Models/PcProtocol.cs index 3b2cb013b..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PcProtocol.cs +++ b/Samples/test/end-to-end/network/Client/Models/PcProtocol.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for PcProtocol. - /// - public static class PcProtocol - { - public const string TCP = "TCP"; - public const string UDP = "UDP"; - public const string Any = "Any"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PcStatus.cs b/Samples/test/end-to-end/network/Client/Models/PcStatus.cs index e8ee62185..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PcStatus.cs +++ b/Samples/test/end-to-end/network/Client/Models/PcStatus.cs @@ -1,21 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for PcStatus. - /// - public static class PcStatus - { - public const string NotStarted = "NotStarted"; - public const string Running = "Running"; - public const string Stopped = "Stopped"; - public const string Error = "Error"; - public const string Unknown = "Unknown"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Probe.cs b/Samples/test/end-to-end/network/Client/Models/Probe.cs index 7dca4edb8..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Probe.cs +++ b/Samples/test/end-to-end/network/Client/Models/Probe.cs @@ -1,170 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A load balancer probe. - /// - [JsonTransformation] - public partial class Probe : SubResource - { - /// - /// Initializes a new instance of the Probe class. - /// - public Probe() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Probe class. - /// - /// The protocol of the end point. Possible - /// values are: 'Http' or 'Tcp'. If 'Tcp' is specified, a received ACK - /// is required for the probe to be successful. If 'Http' is specified, - /// a 200 OK response from the specifies URI is required for the probe - /// to be successful. Possible values include: 'Http', 'Tcp' - /// The port for communicating the probe. Possible - /// values range from 1 to 65535, inclusive. - /// Resource ID. - /// The load balancer rules that use - /// this probe. - /// The interval, in seconds, for how - /// frequently to probe the endpoint for health status. Typically, the - /// interval is slightly less than half the allocated timeout period - /// (in seconds) which allows two full probes before taking the - /// instance out of rotation. The default value is 15, the minimum - /// value is 5. - /// The number of probes where if no - /// response, will result in stopping further traffic from being - /// delivered to the endpoint. This values allows endpoints to be taken - /// out of rotation faster or slower than the typical times used in - /// Azure. - /// The URI used for requesting health status - /// from the VM. Path is required if a protocol is set to http. - /// Otherwise, it is not allowed. There is no default value. - /// Gets the provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// Gets name of the resource that is unique within - /// a resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public Probe(string protocol, int port, string id = default(string), IList loadBalancingRules = default(IList), int? intervalInSeconds = default(int?), int? numberOfProbes = default(int?), string requestPath = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - LoadBalancingRules = loadBalancingRules; - Protocol = protocol; - Port = port; - IntervalInSeconds = intervalInSeconds; - NumberOfProbes = numberOfProbes; - RequestPath = requestPath; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the load balancer rules that use this probe. - /// - [JsonProperty(PropertyName = "properties.loadBalancingRules")] - public IList LoadBalancingRules { get; private set; } - - /// - /// Gets or sets the protocol of the end point. Possible values are: - /// 'Http' or 'Tcp'. If 'Tcp' is specified, a received ACK is required - /// for the probe to be successful. If 'Http' is specified, a 200 OK - /// response from the specifies URI is required for the probe to be - /// successful. Possible values include: 'Http', 'Tcp' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets the port for communicating the probe. Possible values - /// range from 1 to 65535, inclusive. - /// - [JsonProperty(PropertyName = "properties.port")] - public int Port { get; set; } - - /// - /// Gets or sets the interval, in seconds, for how frequently to probe - /// the endpoint for health status. Typically, the interval is slightly - /// less than half the allocated timeout period (in seconds) which - /// allows two full probes before taking the instance out of rotation. - /// The default value is 15, the minimum value is 5. - /// - [JsonProperty(PropertyName = "properties.intervalInSeconds")] - public int? IntervalInSeconds { get; set; } - - /// - /// Gets or sets the number of probes where if no response, will result - /// in stopping further traffic from being delivered to the endpoint. - /// This values allows endpoints to be taken out of rotation faster or - /// slower than the typical times used in Azure. - /// - [JsonProperty(PropertyName = "properties.numberOfProbes")] - public int? NumberOfProbes { get; set; } - - /// - /// Gets or sets the URI used for requesting health status from the VM. - /// Path is required if a protocol is set to http. Otherwise, it is not - /// allowed. There is no default value. - /// - [JsonProperty(PropertyName = "properties.requestPath")] - public string RequestPath { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets name of the resource that is unique within a resource group. - /// This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Protocol == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Protocol"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ProbeProtocol.cs b/Samples/test/end-to-end/network/Client/Models/ProbeProtocol.cs index d74673635..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ProbeProtocol.cs +++ b/Samples/test/end-to-end/network/Client/Models/ProbeProtocol.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ProbeProtocol. - /// - public static class ProbeProtocol - { - public const string Http = "Http"; - public const string Tcp = "Tcp"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ProcessorArchitecture.cs b/Samples/test/end-to-end/network/Client/Models/ProcessorArchitecture.cs index 6b0837af7..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ProcessorArchitecture.cs +++ b/Samples/test/end-to-end/network/Client/Models/ProcessorArchitecture.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ProcessorArchitecture. - /// - public static class ProcessorArchitecture - { - public const string Amd64 = "Amd64"; - public const string X86 = "X86"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Protocol.cs b/Samples/test/end-to-end/network/Client/Models/Protocol.cs index a1ee39fff..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Protocol.cs +++ b/Samples/test/end-to-end/network/Client/Models/Protocol.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for Protocol. - /// - public static class Protocol - { - public const string TCP = "TCP"; - public const string UDP = "UDP"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ProvisioningState.cs b/Samples/test/end-to-end/network/Client/Models/ProvisioningState.cs index 14ff63220..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ProvisioningState.cs +++ b/Samples/test/end-to-end/network/Client/Models/ProvisioningState.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ProvisioningState. - /// - public static class ProvisioningState - { - public const string Succeeded = "Succeeded"; - public const string Updating = "Updating"; - public const string Deleting = "Deleting"; - public const string Failed = "Failed"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PublicIPAddress.cs b/Samples/test/end-to-end/network/Client/Models/PublicIPAddress.cs index 833c9f504..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PublicIPAddress.cs +++ b/Samples/test/end-to-end/network/Client/Models/PublicIPAddress.cs @@ -1,134 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Public IP address resource. - /// - [JsonTransformation] - public partial class PublicIPAddress : Resource - { - /// - /// Initializes a new instance of the PublicIPAddress class. - /// - public PublicIPAddress() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PublicIPAddress class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// The public IP allocation - /// method. Possible values are: 'Static' and 'Dynamic'. Possible - /// values include: 'Static', 'Dynamic' - /// The public IP address version. - /// Possible values are: 'IPv4' and 'IPv6'. Possible values include: - /// 'IPv4', 'IPv6' - /// The FQDN of the DNS record associated - /// with the public IP address. - /// The idle timeout of the public - /// IP address. - /// The resource GUID property of the public - /// IP resource. - /// The provisioning state of the - /// PublicIP resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// A unique read-only string that changes whenever - /// the resource is updated. - public PublicIPAddress(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string publicIPAllocationMethod = default(string), string publicIPAddressVersion = default(string), IPConfiguration ipConfiguration = default(IPConfiguration), PublicIPAddressDnsSettings dnsSettings = default(PublicIPAddressDnsSettings), string ipAddress = default(string), int? idleTimeoutInMinutes = default(int?), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - PublicIPAllocationMethod = publicIPAllocationMethod; - PublicIPAddressVersion = publicIPAddressVersion; - IpConfiguration = ipConfiguration; - DnsSettings = dnsSettings; - IpAddress = ipAddress; - IdleTimeoutInMinutes = idleTimeoutInMinutes; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the public IP allocation method. Possible values are: - /// 'Static' and 'Dynamic'. Possible values include: 'Static', - /// 'Dynamic' - /// - [JsonProperty(PropertyName = "properties.publicIPAllocationMethod")] - public string PublicIPAllocationMethod { get; set; } - - /// - /// Gets or sets the public IP address version. Possible values are: - /// 'IPv4' and 'IPv6'. Possible values include: 'IPv4', 'IPv6' - /// - [JsonProperty(PropertyName = "properties.publicIPAddressVersion")] - public string PublicIPAddressVersion { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.ipConfiguration")] - public IPConfiguration IpConfiguration { get; private set; } - - /// - /// Gets or sets the FQDN of the DNS record associated with the public - /// IP address. - /// - [JsonProperty(PropertyName = "properties.dnsSettings")] - public PublicIPAddressDnsSettings DnsSettings { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.ipAddress")] - public string IpAddress { get; set; } - - /// - /// Gets or sets the idle timeout of the public IP address. - /// - [JsonProperty(PropertyName = "properties.idleTimeoutInMinutes")] - public int? IdleTimeoutInMinutes { get; set; } - - /// - /// Gets or sets the resource GUID property of the public IP resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets or sets the provisioning state of the PublicIP resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/PublicIPAddressDnsSettings.cs b/Samples/test/end-to-end/network/Client/Models/PublicIPAddressDnsSettings.cs index 7c77fefaa..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/PublicIPAddressDnsSettings.cs +++ b/Samples/test/end-to-end/network/Client/Models/PublicIPAddressDnsSettings.cs @@ -1,84 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Contains FQDN of the DNS record associated with the public IP address - /// - public partial class PublicIPAddressDnsSettings - { - /// - /// Initializes a new instance of the PublicIPAddressDnsSettings class. - /// - public PublicIPAddressDnsSettings() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PublicIPAddressDnsSettings class. - /// - /// Gets or sets the Domain name - /// label.The concatenation of the domain name label and the - /// regionalized DNS zone make up the fully qualified domain name - /// associated with the public IP address. If a domain name label is - /// specified, an A DNS record is created for the public IP in the - /// Microsoft Azure DNS system. - /// Gets the FQDN, Fully qualified domain name of - /// the A DNS record associated with the public IP. This is the - /// concatenation of the domainNameLabel and the regionalized DNS - /// zone. - /// Gets or Sets the Reverse FQDN. A - /// user-visible, fully qualified domain name that resolves to this - /// public IP address. If the reverseFqdn is specified, then a PTR DNS - /// record is created pointing from the IP address in the in-addr.arpa - /// domain to the reverse FQDN. - public PublicIPAddressDnsSettings(string domainNameLabel = default(string), string fqdn = default(string), string reverseFqdn = default(string)) - { - DomainNameLabel = domainNameLabel; - Fqdn = fqdn; - ReverseFqdn = reverseFqdn; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the Domain name label.The concatenation of the domain - /// name label and the regionalized DNS zone make up the fully - /// qualified domain name associated with the public IP address. If a - /// domain name label is specified, an A DNS record is created for the - /// public IP in the Microsoft Azure DNS system. - /// - [JsonProperty(PropertyName = "domainNameLabel")] - public string DomainNameLabel { get; set; } - - /// - /// Gets the FQDN, Fully qualified domain name of the A DNS record - /// associated with the public IP. This is the concatenation of the - /// domainNameLabel and the regionalized DNS zone. - /// - [JsonProperty(PropertyName = "fqdn")] - public string Fqdn { get; set; } - - /// - /// Gets or Sets the Reverse FQDN. A user-visible, fully qualified - /// domain name that resolves to this public IP address. If the - /// reverseFqdn is specified, then a PTR DNS record is created pointing - /// from the IP address in the in-addr.arpa domain to the reverse FQDN. - /// - [JsonProperty(PropertyName = "reverseFqdn")] - public string ReverseFqdn { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/QueryTroubleshootingParameters.cs b/Samples/test/end-to-end/network/Client/Models/QueryTroubleshootingParameters.cs index 6984ef797..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/QueryTroubleshootingParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/QueryTroubleshootingParameters.cs @@ -1,66 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define the resource to query the troubleshooting - /// result. - /// - public partial class QueryTroubleshootingParameters - { - /// - /// Initializes a new instance of the QueryTroubleshootingParameters - /// class. - /// - public QueryTroubleshootingParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the QueryTroubleshootingParameters - /// class. - /// - /// The target resource ID to query the - /// troubleshooting result. - public QueryTroubleshootingParameters(string targetResourceId) - { - TargetResourceId = targetResourceId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the target resource ID to query the troubleshooting - /// result. - /// - [JsonProperty(PropertyName = "targetResourceId")] - public string TargetResourceId { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceId"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Resource.cs b/Samples/test/end-to-end/network/Client/Models/Resource.cs index c4bc501fc..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Resource.cs +++ b/Samples/test/end-to-end/network/Client/Models/Resource.cs @@ -1,80 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class Resource : IResource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource ID. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - /// - /// Gets resource name. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets resource type. - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets or sets resource location. - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets resource tags. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ResourceNavigationLink.cs b/Samples/test/end-to-end/network/Client/Models/ResourceNavigationLink.cs index 59eeaecc2..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ResourceNavigationLink.cs +++ b/Samples/test/end-to-end/network/Client/Models/ResourceNavigationLink.cs @@ -1,91 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// ResourceNavigationLink resource. - /// - [JsonTransformation] - public partial class ResourceNavigationLink : SubResource - { - /// - /// Initializes a new instance of the ResourceNavigationLink class. - /// - public ResourceNavigationLink() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the ResourceNavigationLink class. - /// - /// Resource ID. - /// Resource type of the linked - /// resource. - /// Link to the external resource - /// Provisioning state of the - /// ResourceNavigationLink resource. - /// Name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public ResourceNavigationLink(string id = default(string), string linkedResourceType = default(string), string link = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - LinkedResourceType = linkedResourceType; - Link = link; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource type of the linked resource. - /// - [JsonProperty(PropertyName = "properties.linkedResourceType")] - public string LinkedResourceType { get; set; } - - /// - /// Gets or sets link to the external resource - /// - [JsonProperty(PropertyName = "properties.link")] - public string Link { get; set; } - - /// - /// Gets provisioning state of the ResourceNavigationLink resource. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets or sets name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/RetentionPolicyParameters.cs b/Samples/test/end-to-end/network/Client/Models/RetentionPolicyParameters.cs index ebbd2e817..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/RetentionPolicyParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/RetentionPolicyParameters.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define the retention policy for flow log. - /// - public partial class RetentionPolicyParameters - { - /// - /// Initializes a new instance of the RetentionPolicyParameters class. - /// - public RetentionPolicyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the RetentionPolicyParameters class. - /// - /// Number of days to retain flow log - /// records. - /// Flag to enable/disable retention. - public RetentionPolicyParameters(int? days = default(int?), bool? enabled = default(bool?)) - { - Days = days; - Enabled = enabled; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets number of days to retain flow log records. - /// - [JsonProperty(PropertyName = "days")] - public int? Days { get; set; } - - /// - /// Gets or sets flag to enable/disable retention. - /// - [JsonProperty(PropertyName = "enabled")] - public bool? Enabled { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Route.cs b/Samples/test/end-to-end/network/Client/Models/Route.cs index d4d9210d0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Route.cs +++ b/Samples/test/end-to-end/network/Client/Models/Route.cs @@ -1,126 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Route resource - /// - [JsonTransformation] - public partial class Route : SubResource - { - /// - /// Initializes a new instance of the Route class. - /// - public Route() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Route class. - /// - /// The type of Azure hop the packet should - /// be sent to. Possible values are: 'VirtualNetworkGateway', - /// 'VnetLocal', 'Internet', 'VirtualAppliance', and 'None'. Possible - /// values include: 'VirtualNetworkGateway', 'VnetLocal', 'Internet', - /// 'VirtualAppliance', 'None' - /// Resource ID. - /// The destination CIDR to which the route - /// applies. - /// The IP address packets should be - /// forwarded to. Next hop values are only allowed in routes where the - /// next hop type is VirtualAppliance. - /// The provisioning state of the - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public Route(string nextHopType, string id = default(string), string addressPrefix = default(string), string nextHopIpAddress = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - AddressPrefix = addressPrefix; - NextHopType = nextHopType; - NextHopIpAddress = nextHopIpAddress; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the destination CIDR to which the route applies. - /// - [JsonProperty(PropertyName = "properties.addressPrefix")] - public string AddressPrefix { get; set; } - - /// - /// Gets or sets the type of Azure hop the packet should be sent to. - /// Possible values are: 'VirtualNetworkGateway', 'VnetLocal', - /// 'Internet', 'VirtualAppliance', and 'None'. Possible values - /// include: 'VirtualNetworkGateway', 'VnetLocal', 'Internet', - /// 'VirtualAppliance', 'None' - /// - [JsonProperty(PropertyName = "properties.nextHopType")] - public string NextHopType { get; set; } - - /// - /// Gets or sets the IP address packets should be forwarded to. Next - /// hop values are only allowed in routes where the next hop type is - /// VirtualAppliance. - /// - [JsonProperty(PropertyName = "properties.nextHopIpAddress")] - public string NextHopIpAddress { get; set; } - - /// - /// Gets or sets the provisioning state of the resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (NextHopType == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "NextHopType"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/RouteFilter.cs b/Samples/test/end-to-end/network/Client/Models/RouteFilter.cs index 345e4ca39..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/RouteFilter.cs +++ b/Samples/test/end-to-end/network/Client/Models/RouteFilter.cs @@ -1,90 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Route Filter Resource. - /// - [JsonTransformation] - public partial class RouteFilter : Resource - { - /// - /// Initializes a new instance of the RouteFilter class. - /// - public RouteFilter() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the RouteFilter class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// Collection of RouteFilterRules contained within - /// a route filter. - /// A collection of references to express route - /// circuit peerings. - /// The provisioning state of the - /// resource. Possible values are: 'Updating', 'Deleting', 'Succeeded' - /// and 'Failed'. - /// Gets a unique read-only string that changes - /// whenever the resource is updated. - public RouteFilter(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IList rules = default(IList), IList peerings = default(IList), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - Rules = rules; - Peerings = peerings; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets collection of RouteFilterRules contained within a - /// route filter. - /// - [JsonProperty(PropertyName = "properties.rules")] - public IList Rules { get; set; } - - /// - /// Gets a collection of references to express route circuit peerings. - /// - [JsonProperty(PropertyName = "properties.peerings")] - public IList Peerings { get; private set; } - - /// - /// Gets the provisioning state of the resource. Possible values are: - /// 'Updating', 'Deleting', 'Succeeded' and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/RouteFilterRule.cs b/Samples/test/end-to-end/network/Client/Models/RouteFilterRule.cs index 578f4b7dc..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/RouteFilterRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/RouteFilterRule.cs @@ -1,144 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Route Filter Rule Resource - /// - [JsonTransformation] - public partial class RouteFilterRule : SubResource - { - /// - /// Initializes a new instance of the RouteFilterRule class. - /// - public RouteFilterRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the RouteFilterRule class. - /// - /// The access type of the rule. Valid values are: - /// 'Allow', 'Deny'. Possible values include: 'Allow', 'Deny' - /// The collection for bgp community values - /// to filter on. e.g. ['12076:5010','12076:5020'] - /// Resource ID. - /// The provisioning state of the - /// resource. Possible values are: 'Updating', 'Deleting', 'Succeeded' - /// and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// Resource location. - /// A unique read-only string that changes whenever - /// the resource is updated. - /// Resource tags. - public RouteFilterRule(string access, IList communities, string id = default(string), string provisioningState = default(string), string name = default(string), string location = default(string), string etag = default(string), IDictionary tags = default(IDictionary)) - : base(id) - { - Access = access; - Communities = communities; - ProvisioningState = provisioningState; - Name = name; - Location = location; - Etag = etag; - Tags = tags; - CustomInit(); - } - /// - /// Static constructor for RouteFilterRule class. - /// - static RouteFilterRule() - { - RouteFilterRuleType = "Community"; - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the access type of the rule. Valid values are: - /// 'Allow', 'Deny'. Possible values include: 'Allow', 'Deny' - /// - [JsonProperty(PropertyName = "properties.access")] - public string Access { get; set; } - - /// - /// Gets or sets the collection for bgp community values to filter on. - /// e.g. ['12076:5010','12076:5020'] - /// - [JsonProperty(PropertyName = "properties.communities")] - public IList Communities { get; set; } - - /// - /// Gets the provisioning state of the resource. Possible values are: - /// 'Updating', 'Deleting', 'Succeeded' and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets the name of the resource that is unique within a resource - /// group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets or sets resource location. - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; private set; } - - /// - /// Gets or sets resource tags. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// The rule type of the rule. Valid value is: 'Community' - /// - [JsonProperty(PropertyName = "properties.routeFilterRuleType")] - public static string RouteFilterRuleType { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Access == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Access"); - } - if (Communities == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Communities"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/RouteNextHopType.cs b/Samples/test/end-to-end/network/Client/Models/RouteNextHopType.cs index 0306730ed..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/RouteNextHopType.cs +++ b/Samples/test/end-to-end/network/Client/Models/RouteNextHopType.cs @@ -1,21 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for RouteNextHopType. - /// - public static class RouteNextHopType - { - public const string VirtualNetworkGateway = "VirtualNetworkGateway"; - public const string VnetLocal = "VnetLocal"; - public const string Internet = "Internet"; - public const string VirtualAppliance = "VirtualAppliance"; - public const string None = "None"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/RouteTable.cs b/Samples/test/end-to-end/network/Client/Models/RouteTable.cs index e1dea9f72..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/RouteTable.cs +++ b/Samples/test/end-to-end/network/Client/Models/RouteTable.cs @@ -1,89 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Route table resource. - /// - [JsonTransformation] - public partial class RouteTable : Resource - { - /// - /// Initializes a new instance of the RouteTable class. - /// - public RouteTable() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the RouteTable class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// Collection of routes contained within a route - /// table. - /// A collection of references to - /// subnets. - /// The provisioning state of the - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// Gets a unique read-only string that changes - /// whenever the resource is updated. - public RouteTable(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IList routes = default(IList), IList subnets = default(IList), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - Routes = routes; - Subnets = subnets; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets collection of routes contained within a route table. - /// - [JsonProperty(PropertyName = "properties.routes")] - public IList Routes { get; set; } - - /// - /// Gets a collection of references to subnets. - /// - [JsonProperty(PropertyName = "properties.subnets")] - public IList Subnets { get; private set; } - - /// - /// Gets or sets the provisioning state of the resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityGroupNetworkInterface.cs b/Samples/test/end-to-end/network/Client/Models/SecurityGroupNetworkInterface.cs index f5643002f..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityGroupNetworkInterface.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityGroupNetworkInterface.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Network interface and all its associated security rules. - /// - public partial class SecurityGroupNetworkInterface - { - /// - /// Initializes a new instance of the SecurityGroupNetworkInterface - /// class. - /// - public SecurityGroupNetworkInterface() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SecurityGroupNetworkInterface - /// class. - /// - /// ID of the network interface. - public SecurityGroupNetworkInterface(string id = default(string), SecurityRuleAssociations securityRuleAssociations = default(SecurityRuleAssociations)) - { - Id = id; - SecurityRuleAssociations = securityRuleAssociations; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets ID of the network interface. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "securityRuleAssociations")] - public SecurityRuleAssociations SecurityRuleAssociations { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewParameters.cs b/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewParameters.cs index 810651d90..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewParameters.cs @@ -1,63 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define the VM to check security groups for. - /// - public partial class SecurityGroupViewParameters - { - /// - /// Initializes a new instance of the SecurityGroupViewParameters - /// class. - /// - public SecurityGroupViewParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SecurityGroupViewParameters - /// class. - /// - /// ID of the target VM. - public SecurityGroupViewParameters(string targetResourceId) - { - TargetResourceId = targetResourceId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets ID of the target VM. - /// - [JsonProperty(PropertyName = "targetResourceId")] - public string TargetResourceId { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceId"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewResult.cs b/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewResult.cs index 373e55b13..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityGroupViewResult.cs @@ -1,50 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The information about security rules applied to the specified VM. - /// - public partial class SecurityGroupViewResult - { - /// - /// Initializes a new instance of the SecurityGroupViewResult class. - /// - public SecurityGroupViewResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SecurityGroupViewResult class. - /// - /// List of network interfaces on the - /// specified VM. - public SecurityGroupViewResult(IList networkInterfaces = default(IList)) - { - NetworkInterfaces = networkInterfaces; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets list of network interfaces on the specified VM. - /// - [JsonProperty(PropertyName = "networkInterfaces")] - public IList NetworkInterfaces { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityRule.cs b/Samples/test/end-to-end/network/Client/Models/SecurityRule.cs index 57432f59c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityRule.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityRule.cs @@ -1,219 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Network security rule. - /// - [JsonTransformation] - public partial class SecurityRule : SubResource - { - /// - /// Initializes a new instance of the SecurityRule class. - /// - public SecurityRule() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SecurityRule class. - /// - /// Network protocol this rule applies to. - /// Possible values are 'Tcp', 'Udp', and '*'. Possible values include: - /// 'Tcp', 'Udp', '*' - /// The CIDR or source IP range. - /// Asterix '*' can also be used to match all source IPs. Default tags - /// such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can - /// also be used. If this is an ingress rule, specifies where network - /// traffic originates from. - /// The destination address - /// prefix. CIDR or source IP range. Asterix '*' can also be used to - /// match all source IPs. Default tags such as 'VirtualNetwork', - /// 'AzureLoadBalancer' and 'Internet' can also be used. - /// The network traffic is allowed or denied. - /// Possible values are: 'Allow' and 'Deny'. Possible values include: - /// 'Allow', 'Deny' - /// The direction of the rule. The direction - /// specifies if rule will be evaluated on incoming or outcoming - /// traffic. Possible values are: 'Inbound' and 'Outbound'. Possible - /// values include: 'Inbound', 'Outbound' - /// Resource ID. - /// A description for this rule. Restricted - /// to 140 chars. - /// The source port or range. Integer or - /// range between 0 and 65535. Asterix '*' can also be used to match - /// all ports. - /// The destination port or range. - /// Integer or range between 0 and 65535. Asterix '*' can also be used - /// to match all ports. - /// The priority of the rule. The value can be - /// between 100 and 4096. The priority number must be unique for each - /// rule in the collection. The lower the priority number, the higher - /// the priority of the rule. - /// The provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public SecurityRule(string protocol, string sourceAddressPrefix, string destinationAddressPrefix, string access, string direction, string id = default(string), string description = default(string), string sourcePortRange = default(string), string destinationPortRange = default(string), int? priority = default(int?), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Description = description; - Protocol = protocol; - SourcePortRange = sourcePortRange; - DestinationPortRange = destinationPortRange; - SourceAddressPrefix = sourceAddressPrefix; - DestinationAddressPrefix = destinationAddressPrefix; - Access = access; - Priority = priority; - Direction = direction; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a description for this rule. Restricted to 140 chars. - /// - [JsonProperty(PropertyName = "properties.description")] - public string Description { get; set; } - - /// - /// Gets or sets network protocol this rule applies to. Possible values - /// are 'Tcp', 'Udp', and '*'. Possible values include: 'Tcp', 'Udp', - /// '*' - /// - [JsonProperty(PropertyName = "properties.protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets the source port or range. Integer or range between 0 - /// and 65535. Asterix '*' can also be used to match all ports. - /// - [JsonProperty(PropertyName = "properties.sourcePortRange")] - public string SourcePortRange { get; set; } - - /// - /// Gets or sets the destination port or range. Integer or range - /// between 0 and 65535. Asterix '*' can also be used to match all - /// ports. - /// - [JsonProperty(PropertyName = "properties.destinationPortRange")] - public string DestinationPortRange { get; set; } - - /// - /// Gets or sets the CIDR or source IP range. Asterix '*' can also be - /// used to match all source IPs. Default tags such as - /// 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be - /// used. If this is an ingress rule, specifies where network traffic - /// originates from. - /// - [JsonProperty(PropertyName = "properties.sourceAddressPrefix")] - public string SourceAddressPrefix { get; set; } - - /// - /// Gets or sets the destination address prefix. CIDR or source IP - /// range. Asterix '*' can also be used to match all source IPs. - /// Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and - /// 'Internet' can also be used. - /// - [JsonProperty(PropertyName = "properties.destinationAddressPrefix")] - public string DestinationAddressPrefix { get; set; } - - /// - /// Gets or sets the network traffic is allowed or denied. Possible - /// values are: 'Allow' and 'Deny'. Possible values include: 'Allow', - /// 'Deny' - /// - [JsonProperty(PropertyName = "properties.access")] - public string Access { get; set; } - - /// - /// Gets or sets the priority of the rule. The value can be between 100 - /// and 4096. The priority number must be unique for each rule in the - /// collection. The lower the priority number, the higher the priority - /// of the rule. - /// - [JsonProperty(PropertyName = "properties.priority")] - public int? Priority { get; set; } - - /// - /// Gets or sets the direction of the rule. The direction specifies if - /// rule will be evaluated on incoming or outcoming traffic. Possible - /// values are: 'Inbound' and 'Outbound'. Possible values include: - /// 'Inbound', 'Outbound' - /// - [JsonProperty(PropertyName = "properties.direction")] - public string Direction { get; set; } - - /// - /// Gets or sets the provisioning state of the public IP resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Protocol == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Protocol"); - } - if (SourceAddressPrefix == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SourceAddressPrefix"); - } - if (DestinationAddressPrefix == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "DestinationAddressPrefix"); - } - if (Access == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Access"); - } - if (Direction == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Direction"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityRuleAccess.cs b/Samples/test/end-to-end/network/Client/Models/SecurityRuleAccess.cs index 8a09c7068..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityRuleAccess.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityRuleAccess.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for SecurityRuleAccess. - /// - public static class SecurityRuleAccess - { - public const string Allow = "Allow"; - public const string Deny = "Deny"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityRuleAssociations.cs b/Samples/test/end-to-end/network/Client/Models/SecurityRuleAssociations.cs index 3e132e328..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityRuleAssociations.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityRuleAssociations.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// All security rules associated with the network interface. - /// - public partial class SecurityRuleAssociations - { - /// - /// Initializes a new instance of the SecurityRuleAssociations class. - /// - public SecurityRuleAssociations() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SecurityRuleAssociations class. - /// - /// Collection of default security - /// rules of the network security group. - /// Collection of effective - /// security rules. - public SecurityRuleAssociations(NetworkInterfaceAssociation networkInterfaceAssociation = default(NetworkInterfaceAssociation), SubnetAssociation subnetAssociation = default(SubnetAssociation), IList defaultSecurityRules = default(IList), IList effectiveSecurityRules = default(IList)) - { - NetworkInterfaceAssociation = networkInterfaceAssociation; - SubnetAssociation = subnetAssociation; - DefaultSecurityRules = defaultSecurityRules; - EffectiveSecurityRules = effectiveSecurityRules; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "networkInterfaceAssociation")] - public NetworkInterfaceAssociation NetworkInterfaceAssociation { get; set; } - - /// - /// - [JsonProperty(PropertyName = "subnetAssociation")] - public SubnetAssociation SubnetAssociation { get; set; } - - /// - /// Gets or sets collection of default security rules of the network - /// security group. - /// - [JsonProperty(PropertyName = "defaultSecurityRules")] - public IList DefaultSecurityRules { get; set; } - - /// - /// Gets or sets collection of effective security rules. - /// - [JsonProperty(PropertyName = "effectiveSecurityRules")] - public IList EffectiveSecurityRules { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityRuleDirection.cs b/Samples/test/end-to-end/network/Client/Models/SecurityRuleDirection.cs index 1a5d689a4..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityRuleDirection.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityRuleDirection.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for SecurityRuleDirection. - /// - public static class SecurityRuleDirection - { - public const string Inbound = "Inbound"; - public const string Outbound = "Outbound"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SecurityRuleProtocol.cs b/Samples/test/end-to-end/network/Client/Models/SecurityRuleProtocol.cs index ac5631fb2..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SecurityRuleProtocol.cs +++ b/Samples/test/end-to-end/network/Client/Models/SecurityRuleProtocol.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for SecurityRuleProtocol. - /// - public static class SecurityRuleProtocol - { - public const string Tcp = "Tcp"; - public const string Udp = "Udp"; - public const string Asterisk = "*"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/ServiceProviderProvisioningState.cs b/Samples/test/end-to-end/network/Client/Models/ServiceProviderProvisioningState.cs index d5295a56c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/ServiceProviderProvisioningState.cs +++ b/Samples/test/end-to-end/network/Client/Models/ServiceProviderProvisioningState.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for ServiceProviderProvisioningState. - /// - public static class ServiceProviderProvisioningState - { - public const string NotProvisioned = "NotProvisioned"; - public const string Provisioning = "Provisioning"; - public const string Provisioned = "Provisioned"; - public const string Deprovisioning = "Deprovisioning"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SubResource.cs b/Samples/test/end-to-end/network/Client/Models/SubResource.cs index 466304902..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SubResource.cs +++ b/Samples/test/end-to-end/network/Client/Models/SubResource.cs @@ -1,46 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Linq; - - public partial class SubResource : IResource - { - /// - /// Initializes a new instance of the SubResource class. - /// - public SubResource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubResource class. - /// - /// Resource ID. - public SubResource(string id = default(string)) - { - Id = id; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource ID. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Subnet.cs b/Samples/test/end-to-end/network/Client/Models/Subnet.cs index 3559689fe..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Subnet.cs +++ b/Samples/test/end-to-end/network/Client/Models/Subnet.cs @@ -1,122 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Subnet in a virtual network resource. - /// - [JsonTransformation] - public partial class Subnet : SubResource - { - /// - /// Initializes a new instance of the Subnet class. - /// - public Subnet() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Subnet class. - /// - /// Resource ID. - /// The address prefix for the - /// subnet. - /// The reference of the - /// NetworkSecurityGroup resource. - /// The reference of the RouteTable - /// resource. - /// Gets an array of references to the - /// network interface IP configurations using subnet. - /// Gets an array of references - /// to the external resources using subnet. - /// The provisioning state of the - /// resource. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public Subnet(string id = default(string), string addressPrefix = default(string), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), RouteTable routeTable = default(RouteTable), IList ipConfigurations = default(IList), IList resourceNavigationLinks = default(IList), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - AddressPrefix = addressPrefix; - NetworkSecurityGroup = networkSecurityGroup; - RouteTable = routeTable; - IpConfigurations = ipConfigurations; - ResourceNavigationLinks = resourceNavigationLinks; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the address prefix for the subnet. - /// - [JsonProperty(PropertyName = "properties.addressPrefix")] - public string AddressPrefix { get; set; } - - /// - /// Gets or sets the reference of the NetworkSecurityGroup resource. - /// - [JsonProperty(PropertyName = "properties.networkSecurityGroup")] - public NetworkSecurityGroup NetworkSecurityGroup { get; set; } - - /// - /// Gets or sets the reference of the RouteTable resource. - /// - [JsonProperty(PropertyName = "properties.routeTable")] - public RouteTable RouteTable { get; set; } - - /// - /// Gets an array of references to the network interface IP - /// configurations using subnet. - /// - [JsonProperty(PropertyName = "properties.ipConfigurations")] - public IList IpConfigurations { get; private set; } - - /// - /// Gets an array of references to the external resources using subnet. - /// - [JsonProperty(PropertyName = "properties.resourceNavigationLinks")] - public IList ResourceNavigationLinks { get; set; } - - /// - /// Gets or sets the provisioning state of the resource. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/SubnetAssociation.cs b/Samples/test/end-to-end/network/Client/Models/SubnetAssociation.cs index 52b57f16d..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/SubnetAssociation.cs +++ b/Samples/test/end-to-end/network/Client/Models/SubnetAssociation.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Network interface and its custom security rules. - /// - public partial class SubnetAssociation - { - /// - /// Initializes a new instance of the SubnetAssociation class. - /// - public SubnetAssociation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubnetAssociation class. - /// - /// Subnet ID. - /// Collection of custom security - /// rules. - public SubnetAssociation(string id = default(string), IList securityRules = default(IList)) - { - Id = id; - SecurityRules = securityRules; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets subnet ID. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets or sets collection of custom security rules. - /// - [JsonProperty(PropertyName = "securityRules")] - public IList SecurityRules { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Topology.cs b/Samples/test/end-to-end/network/Client/Models/Topology.cs index ceef777b9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Topology.cs +++ b/Samples/test/end-to-end/network/Client/Models/Topology.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Topology of the specified resource group. - /// - public partial class Topology - { - /// - /// Initializes a new instance of the Topology class. - /// - public Topology() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Topology class. - /// - /// GUID representing the operation id. - /// The datetime when the topology was - /// initially created for the resource group. - /// The datetime when the topology was last - /// modified. - public Topology(string id = default(string), System.DateTime? createdDateTime = default(System.DateTime?), System.DateTime? lastModified = default(System.DateTime?), IList resources = default(IList)) - { - Id = id; - CreatedDateTime = createdDateTime; - LastModified = lastModified; - Resources = resources; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets GUID representing the operation id. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets the datetime when the topology was initially created for the - /// resource group. - /// - [JsonProperty(PropertyName = "createdDateTime")] - public System.DateTime? CreatedDateTime { get; private set; } - - /// - /// Gets the datetime when the topology was last modified. - /// - [JsonProperty(PropertyName = "lastModified")] - public System.DateTime? LastModified { get; private set; } - - /// - /// - [JsonProperty(PropertyName = "resources")] - public IList Resources { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TopologyAssociation.cs b/Samples/test/end-to-end/network/Client/Models/TopologyAssociation.cs index 94d1b8a1c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TopologyAssociation.cs +++ b/Samples/test/end-to-end/network/Client/Models/TopologyAssociation.cs @@ -1,70 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Resources that have an association with the parent resource. - /// - public partial class TopologyAssociation - { - /// - /// Initializes a new instance of the TopologyAssociation class. - /// - public TopologyAssociation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TopologyAssociation class. - /// - /// The name of the resource that is associated with - /// the parent resource. - /// The ID of the resource that is associated - /// with the parent resource. - /// The association type of the child - /// resource to the parent resource. Possible values include: - /// 'Associated', 'Contains' - public TopologyAssociation(string name = default(string), string resourceId = default(string), string associationType = default(string)) - { - Name = name; - ResourceId = resourceId; - AssociationType = associationType; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the resource that is associated with the - /// parent resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the ID of the resource that is associated with the - /// parent resource. - /// - [JsonProperty(PropertyName = "resourceId")] - public string ResourceId { get; set; } - - /// - /// Gets or sets the association type of the child resource to the - /// parent resource. Possible values include: 'Associated', 'Contains' - /// - [JsonProperty(PropertyName = "associationType")] - public string AssociationType { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TopologyParameters.cs b/Samples/test/end-to-end/network/Client/Models/TopologyParameters.cs index b91a7780a..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TopologyParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/TopologyParameters.cs @@ -1,63 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define the representation of topology. - /// - public partial class TopologyParameters - { - /// - /// Initializes a new instance of the TopologyParameters class. - /// - public TopologyParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TopologyParameters class. - /// - /// The name of the target - /// resource group to perform topology on. - public TopologyParameters(string targetResourceGroupName) - { - TargetResourceGroupName = targetResourceGroupName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the name of the target resource group to perform - /// topology on. - /// - [JsonProperty(PropertyName = "targetResourceGroupName")] - public string TargetResourceGroupName { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceGroupName"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TopologyResource.cs b/Samples/test/end-to-end/network/Client/Models/TopologyResource.cs index 19f96ab9e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TopologyResource.cs +++ b/Samples/test/end-to-end/network/Client/Models/TopologyResource.cs @@ -1,75 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The network resource topology information for the given resource group. - /// - public partial class TopologyResource - { - /// - /// Initializes a new instance of the TopologyResource class. - /// - public TopologyResource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TopologyResource class. - /// - /// Name of the resource. - /// ID of the resource. - /// Resource location. - /// Holds the associations the resource has - /// with other resources in the resource group. - public TopologyResource(string name = default(string), string id = default(string), string location = default(string), IList associations = default(IList)) - { - Name = name; - Id = id; - Location = location; - Associations = associations; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets name of the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets ID of the resource. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - /// - /// Gets or sets resource location. - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets holds the associations the resource has with other - /// resources in the resource group. - /// - [JsonProperty(PropertyName = "associations")] - public IList Associations { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TransportProtocol.cs b/Samples/test/end-to-end/network/Client/Models/TransportProtocol.cs index a0d84f550..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TransportProtocol.cs +++ b/Samples/test/end-to-end/network/Client/Models/TransportProtocol.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for TransportProtocol. - /// - public static class TransportProtocol - { - public const string Udp = "Udp"; - public const string Tcp = "Tcp"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TroubleshootingDetails.cs b/Samples/test/end-to-end/network/Client/Models/TroubleshootingDetails.cs index 37ad01e1e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TroubleshootingDetails.cs +++ b/Samples/test/end-to-end/network/Client/Models/TroubleshootingDetails.cs @@ -1,82 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Information gained from troubleshooting of specified resource. - /// - public partial class TroubleshootingDetails - { - /// - /// Initializes a new instance of the TroubleshootingDetails class. - /// - public TroubleshootingDetails() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TroubleshootingDetails class. - /// - /// The id of the get troubleshoot operation. - /// Reason type of failure. - /// A summary of troubleshooting. - /// Details on troubleshooting results. - /// List of recommended - /// actions. - public TroubleshootingDetails(string id = default(string), string reasonType = default(string), string summary = default(string), string detail = default(string), IList recommendedActions = default(IList)) - { - Id = id; - ReasonType = reasonType; - Summary = summary; - Detail = detail; - RecommendedActions = recommendedActions; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the id of the get troubleshoot operation. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - /// - /// Gets or sets reason type of failure. - /// - [JsonProperty(PropertyName = "reasonType")] - public string ReasonType { get; set; } - - /// - /// Gets or sets a summary of troubleshooting. - /// - [JsonProperty(PropertyName = "summary")] - public string Summary { get; set; } - - /// - /// Gets or sets details on troubleshooting results. - /// - [JsonProperty(PropertyName = "detail")] - public string Detail { get; set; } - - /// - /// Gets or sets list of recommended actions. - /// - [JsonProperty(PropertyName = "recommendedActions")] - public IList RecommendedActions { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TroubleshootingParameters.cs b/Samples/test/end-to-end/network/Client/Models/TroubleshootingParameters.cs index 869b079fa..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TroubleshootingParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/TroubleshootingParameters.cs @@ -1,92 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define the resource to troubleshoot. - /// - [JsonTransformation] - public partial class TroubleshootingParameters - { - /// - /// Initializes a new instance of the TroubleshootingParameters class. - /// - public TroubleshootingParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TroubleshootingParameters class. - /// - /// The target resource to - /// troubleshoot. - /// The ID for the storage account to save the - /// troubleshoot result. - /// The path to the blob to save the - /// troubleshoot result in. - public TroubleshootingParameters(string targetResourceId, string storageId, string storagePath) - { - TargetResourceId = targetResourceId; - StorageId = storageId; - StoragePath = storagePath; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the target resource to troubleshoot. - /// - [JsonProperty(PropertyName = "targetResourceId")] - public string TargetResourceId { get; set; } - - /// - /// Gets or sets the ID for the storage account to save the - /// troubleshoot result. - /// - [JsonProperty(PropertyName = "properties.storageId")] - public string StorageId { get; set; } - - /// - /// Gets or sets the path to the blob to save the troubleshoot result - /// in. - /// - [JsonProperty(PropertyName = "properties.storagePath")] - public string StoragePath { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceId"); - } - if (StorageId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "StorageId"); - } - if (StoragePath == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "StoragePath"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TroubleshootingRecommendedActions.cs b/Samples/test/end-to-end/network/Client/Models/TroubleshootingRecommendedActions.cs index b77cb40db..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TroubleshootingRecommendedActions.cs +++ b/Samples/test/end-to-end/network/Client/Models/TroubleshootingRecommendedActions.cs @@ -1,78 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Recommended actions based on discovered issues. - /// - public partial class TroubleshootingRecommendedActions - { - /// - /// Initializes a new instance of the TroubleshootingRecommendedActions - /// class. - /// - public TroubleshootingRecommendedActions() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TroubleshootingRecommendedActions - /// class. - /// - /// ID of the recommended action. - /// Description of recommended - /// actions. - /// The uri linking to a documentation for the - /// recommended troubleshooting actions. - /// The information from the URI for the - /// recommended troubleshooting actions. - public TroubleshootingRecommendedActions(string actionId = default(string), string actionText = default(string), string actionUri = default(string), string actionUriText = default(string)) - { - ActionId = actionId; - ActionText = actionText; - ActionUri = actionUri; - ActionUriText = actionUriText; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets ID of the recommended action. - /// - [JsonProperty(PropertyName = "actionId")] - public string ActionId { get; set; } - - /// - /// Gets or sets description of recommended actions. - /// - [JsonProperty(PropertyName = "actionText")] - public string ActionText { get; set; } - - /// - /// Gets or sets the uri linking to a documentation for the recommended - /// troubleshooting actions. - /// - [JsonProperty(PropertyName = "actionUri")] - public string ActionUri { get; set; } - - /// - /// Gets or sets the information from the URI for the recommended - /// troubleshooting actions. - /// - [JsonProperty(PropertyName = "actionUriText")] - public string ActionUriText { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TroubleshootingResult.cs b/Samples/test/end-to-end/network/Client/Models/TroubleshootingResult.cs index ea59b68bd..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TroubleshootingResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/TroubleshootingResult.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Troubleshooting information gained from specified resource. - /// - public partial class TroubleshootingResult - { - /// - /// Initializes a new instance of the TroubleshootingResult class. - /// - public TroubleshootingResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TroubleshootingResult class. - /// - /// The start time of the - /// troubleshooting. - /// The end time of the troubleshooting. - /// The result code of the troubleshooting. - /// Information from troubleshooting. - public TroubleshootingResult(System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), string code = default(string), IList results = default(IList)) - { - StartTime = startTime; - EndTime = endTime; - Code = code; - Results = results; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the start time of the troubleshooting. - /// - [JsonProperty(PropertyName = "startTime")] - public System.DateTime? StartTime { get; set; } - - /// - /// Gets or sets the end time of the troubleshooting. - /// - [JsonProperty(PropertyName = "endTime")] - public System.DateTime? EndTime { get; set; } - - /// - /// Gets or sets the result code of the troubleshooting. - /// - [JsonProperty(PropertyName = "code")] - public string Code { get; set; } - - /// - /// Gets or sets information from troubleshooting. - /// - [JsonProperty(PropertyName = "results")] - public IList Results { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/TunnelConnectionHealth.cs b/Samples/test/end-to-end/network/Client/Models/TunnelConnectionHealth.cs index 857729628..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/TunnelConnectionHealth.cs +++ b/Samples/test/end-to-end/network/Client/Models/TunnelConnectionHealth.cs @@ -1,85 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// VirtualNetworkGatewayConnection properties - /// - public partial class TunnelConnectionHealth - { - /// - /// Initializes a new instance of the TunnelConnectionHealth class. - /// - public TunnelConnectionHealth() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TunnelConnectionHealth class. - /// - /// Tunnel name. - /// Virtual network Gateway connection - /// status. Possible values include: 'Unknown', 'Connecting', - /// 'Connected', 'NotConnected' - /// The Ingress Bytes Transferred - /// in this connection - /// The Egress Bytes Transferred - /// in this connection - /// The time at which - /// connection was established in Utc format. - public TunnelConnectionHealth(string tunnel = default(string), string connectionStatus = default(string), long? ingressBytesTransferred = default(long?), long? egressBytesTransferred = default(long?), string lastConnectionEstablishedUtcTime = default(string)) - { - Tunnel = tunnel; - ConnectionStatus = connectionStatus; - IngressBytesTransferred = ingressBytesTransferred; - EgressBytesTransferred = egressBytesTransferred; - LastConnectionEstablishedUtcTime = lastConnectionEstablishedUtcTime; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets tunnel name. - /// - [JsonProperty(PropertyName = "tunnel")] - public string Tunnel { get; private set; } - - /// - /// Gets virtual network Gateway connection status. Possible values - /// include: 'Unknown', 'Connecting', 'Connected', 'NotConnected' - /// - [JsonProperty(PropertyName = "connectionStatus")] - public string ConnectionStatus { get; private set; } - - /// - /// Gets the Ingress Bytes Transferred in this connection - /// - [JsonProperty(PropertyName = "ingressBytesTransferred")] - public long? IngressBytesTransferred { get; private set; } - - /// - /// Gets the Egress Bytes Transferred in this connection - /// - [JsonProperty(PropertyName = "egressBytesTransferred")] - public long? EgressBytesTransferred { get; private set; } - - /// - /// Gets the time at which connection was established in Utc format. - /// - [JsonProperty(PropertyName = "lastConnectionEstablishedUtcTime")] - public string LastConnectionEstablishedUtcTime { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/Usage.cs b/Samples/test/end-to-end/network/Client/Models/Usage.cs index dd9c5c8e3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/Usage.cs +++ b/Samples/test/end-to-end/network/Client/Models/Usage.cs @@ -1,90 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Describes network resource usage. - /// - public partial class Usage - { - /// - /// Initializes a new instance of the Usage class. - /// - public Usage() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Usage class. - /// - /// The current value of the usage. - /// The limit of usage. - /// The name of the type of usage. - public Usage(long currentValue, long limit, UsageName name) - { - CurrentValue = currentValue; - Limit = limit; - Name = name; - CustomInit(); - } - /// - /// Static constructor for Usage class. - /// - static Usage() - { - Unit = "Count"; - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the current value of the usage. - /// - [JsonProperty(PropertyName = "currentValue")] - public long CurrentValue { get; set; } - - /// - /// Gets or sets the limit of usage. - /// - [JsonProperty(PropertyName = "limit")] - public long Limit { get; set; } - - /// - /// Gets or sets the name of the type of usage. - /// - [JsonProperty(PropertyName = "name")] - public UsageName Name { get; set; } - - /// - /// An enum describing the unit of measurement. - /// - [JsonProperty(PropertyName = "unit")] - public static string Unit { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/UsageName.cs b/Samples/test/end-to-end/network/Client/Models/UsageName.cs index a5f914a47..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/UsageName.cs +++ b/Samples/test/end-to-end/network/Client/Models/UsageName.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The usage names. - /// - public partial class UsageName - { - /// - /// Initializes a new instance of the UsageName class. - /// - public UsageName() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsageName class. - /// - /// A string describing the resource name. - /// A localized string describing the - /// resource name. - public UsageName(string value = default(string), string localizedValue = default(string)) - { - Value = value; - LocalizedValue = localizedValue; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a string describing the resource name. - /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets or sets a localized string describing the resource name. - /// - [JsonProperty(PropertyName = "localizedValue")] - public string LocalizedValue { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowParameters.cs b/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowParameters.cs index 643406b01..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowParameters.cs @@ -1,164 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Parameters that define the IP flow to be verified. - /// - public partial class VerificationIPFlowParameters - { - /// - /// Initializes a new instance of the VerificationIPFlowParameters - /// class. - /// - public VerificationIPFlowParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VerificationIPFlowParameters - /// class. - /// - /// The ID of the target resource to - /// perform next-hop on. - /// The direction of the packet represented as - /// a 5-tuple. Possible values include: 'Inbound', 'Outbound' - /// Protocol to be verified on. Possible values - /// include: 'TCP', 'UDP' - /// The local port. Acceptable values are a - /// single integer in the range (0-65535). Support for * for the source - /// port, which depends on the direction. - /// The remote port. Acceptable values are a - /// single integer in the range (0-65535). Support for * for the source - /// port, which depends on the direction. - /// The local IP address. Acceptable - /// values are valid IPv4 addresses. - /// The remote IP address. Acceptable - /// values are valid IPv4 addresses. - /// The NIC ID. (If VM has multiple - /// NICs and IP forwarding is enabled on any of them, then this - /// parameter must be specified. Otherwise optional). - public VerificationIPFlowParameters(string targetResourceId, string direction, string protocol, string localPort, string remotePort, string localIPAddress, string remoteIPAddress, string targetNicResourceId = default(string)) - { - TargetResourceId = targetResourceId; - Direction = direction; - Protocol = protocol; - LocalPort = localPort; - RemotePort = remotePort; - LocalIPAddress = localIPAddress; - RemoteIPAddress = remoteIPAddress; - TargetNicResourceId = targetNicResourceId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the ID of the target resource to perform next-hop on. - /// - [JsonProperty(PropertyName = "targetResourceId")] - public string TargetResourceId { get; set; } - - /// - /// Gets or sets the direction of the packet represented as a 5-tuple. - /// Possible values include: 'Inbound', 'Outbound' - /// - [JsonProperty(PropertyName = "direction")] - public string Direction { get; set; } - - /// - /// Gets or sets protocol to be verified on. Possible values include: - /// 'TCP', 'UDP' - /// - [JsonProperty(PropertyName = "protocol")] - public string Protocol { get; set; } - - /// - /// Gets or sets the local port. Acceptable values are a single integer - /// in the range (0-65535). Support for * for the source port, which - /// depends on the direction. - /// - [JsonProperty(PropertyName = "localPort")] - public string LocalPort { get; set; } - - /// - /// Gets or sets the remote port. Acceptable values are a single - /// integer in the range (0-65535). Support for * for the source port, - /// which depends on the direction. - /// - [JsonProperty(PropertyName = "remotePort")] - public string RemotePort { get; set; } - - /// - /// Gets or sets the local IP address. Acceptable values are valid IPv4 - /// addresses. - /// - [JsonProperty(PropertyName = "localIPAddress")] - public string LocalIPAddress { get; set; } - - /// - /// Gets or sets the remote IP address. Acceptable values are valid - /// IPv4 addresses. - /// - [JsonProperty(PropertyName = "remoteIPAddress")] - public string RemoteIPAddress { get; set; } - - /// - /// Gets or sets the NIC ID. (If VM has multiple NICs and IP forwarding - /// is enabled on any of them, then this parameter must be specified. - /// Otherwise optional). - /// - [JsonProperty(PropertyName = "targetNicResourceId")] - public string TargetNicResourceId { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TargetResourceId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TargetResourceId"); - } - if (Direction == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Direction"); - } - if (Protocol == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Protocol"); - } - if (LocalPort == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "LocalPort"); - } - if (RemotePort == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "RemotePort"); - } - if (LocalIPAddress == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "LocalIPAddress"); - } - if (RemoteIPAddress == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "RemoteIPAddress"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowResult.cs b/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowResult.cs index ab3e47140..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowResult.cs +++ b/Samples/test/end-to-end/network/Client/Models/VerificationIPFlowResult.cs @@ -1,59 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Results of IP flow verification on the target resource. - /// - public partial class VerificationIPFlowResult - { - /// - /// Initializes a new instance of the VerificationIPFlowResult class. - /// - public VerificationIPFlowResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VerificationIPFlowResult class. - /// - /// Indicates whether the traffic is allowed or - /// denied. Possible values include: 'Allow', 'Deny' - /// Name of the rule. If input is not matched - /// against any security rule, it is not displayed. - public VerificationIPFlowResult(string access = default(string), string ruleName = default(string)) - { - Access = access; - RuleName = ruleName; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets indicates whether the traffic is allowed or denied. - /// Possible values include: 'Allow', 'Deny' - /// - [JsonProperty(PropertyName = "access")] - public string Access { get; set; } - - /// - /// Gets or sets name of the rule. If input is not matched against any - /// security rule, it is not displayed. - /// - [JsonProperty(PropertyName = "ruleName")] - public string RuleName { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetwork.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetwork.cs index 4745fc696..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetwork.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetwork.cs @@ -1,120 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Virtual Network resource. - /// - [JsonTransformation] - public partial class VirtualNetwork : Resource - { - /// - /// Initializes a new instance of the VirtualNetwork class. - /// - public VirtualNetwork() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VirtualNetwork class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// The AddressSpace that contains an array - /// of IP address ranges that can be used by subnets. - /// The dhcpOptions that contains an array of - /// DNS servers available to VMs deployed in the virtual - /// network. - /// A list of subnets in a Virtual - /// Network. - /// A list of peerings in a - /// Virtual Network. - /// The resourceGuid property of the Virtual - /// Network resource. - /// The provisioning state of the - /// PublicIP resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// Gets a unique read-only string that changes - /// whenever the resource is updated. - public VirtualNetwork(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), AddressSpace addressSpace = default(AddressSpace), DhcpOptions dhcpOptions = default(DhcpOptions), IList subnets = default(IList), IList virtualNetworkPeerings = default(IList), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - AddressSpace = addressSpace; - DhcpOptions = dhcpOptions; - Subnets = subnets; - VirtualNetworkPeerings = virtualNetworkPeerings; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the AddressSpace that contains an array of IP address - /// ranges that can be used by subnets. - /// - [JsonProperty(PropertyName = "properties.addressSpace")] - public AddressSpace AddressSpace { get; set; } - - /// - /// Gets or sets the dhcpOptions that contains an array of DNS servers - /// available to VMs deployed in the virtual network. - /// - [JsonProperty(PropertyName = "properties.dhcpOptions")] - public DhcpOptions DhcpOptions { get; set; } - - /// - /// Gets or sets a list of subnets in a Virtual Network. - /// - [JsonProperty(PropertyName = "properties.subnets")] - public IList Subnets { get; set; } - - /// - /// Gets or sets a list of peerings in a Virtual Network. - /// - [JsonProperty(PropertyName = "properties.virtualNetworkPeerings")] - public IList VirtualNetworkPeerings { get; set; } - - /// - /// Gets or sets the resourceGuid property of the Virtual Network - /// resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets or sets the provisioning state of the PublicIP resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGateway.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGateway.cs index f4a161762..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGateway.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGateway.cs @@ -1,176 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A common class for general resource information - /// - [JsonTransformation] - public partial class VirtualNetworkGateway : Resource - { - /// - /// Initializes a new instance of the VirtualNetworkGateway class. - /// - public VirtualNetworkGateway() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VirtualNetworkGateway class. - /// - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// IP configurations for virtual - /// network gateway. - /// The type of this virtual network gateway. - /// Possible values are: 'Vpn' and 'ExpressRoute'. Possible values - /// include: 'Vpn', 'ExpressRoute' - /// The type of this virtual network gateway. - /// Possible values are: 'PolicyBased' and 'RouteBased'. Possible - /// values include: 'PolicyBased', 'RouteBased' - /// Whether BGP is enabled for this virtual - /// network gateway or not. - /// ActiveActive flag - /// The reference of the - /// LocalNetworkGateway resource which represents local network site - /// having default routes. Assign Null value in case of removing - /// existing default site setting. - /// The reference of the VirtualNetworkGatewaySku - /// resource which represents the SKU selected for Virtual network - /// gateway. - /// The reference of the - /// VpnClientConfiguration resource which represents the P2S VpnClient - /// configurations. - /// Virtual network gateway's BGP speaker - /// settings. - /// The resource GUID property of the - /// VirtualNetworkGateway resource. - /// The provisioning state of the - /// VirtualNetworkGateway resource. Possible values are: 'Updating', - /// 'Deleting', and 'Failed'. - /// Gets a unique read-only string that changes - /// whenever the resource is updated. - public VirtualNetworkGateway(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IList ipConfigurations = default(IList), string gatewayType = default(string), string vpnType = default(string), bool? enableBgp = default(bool?), bool? activeActive = default(bool?), SubResource gatewayDefaultSite = default(SubResource), VirtualNetworkGatewaySku sku = default(VirtualNetworkGatewaySku), VpnClientConfiguration vpnClientConfiguration = default(VpnClientConfiguration), BgpSettings bgpSettings = default(BgpSettings), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - IpConfigurations = ipConfigurations; - GatewayType = gatewayType; - VpnType = vpnType; - EnableBgp = enableBgp; - ActiveActive = activeActive; - GatewayDefaultSite = gatewayDefaultSite; - Sku = sku; - VpnClientConfiguration = vpnClientConfiguration; - BgpSettings = bgpSettings; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets IP configurations for virtual network gateway. - /// - [JsonProperty(PropertyName = "properties.ipConfigurations")] - public IList IpConfigurations { get; set; } - - /// - /// Gets or sets the type of this virtual network gateway. Possible - /// values are: 'Vpn' and 'ExpressRoute'. Possible values include: - /// 'Vpn', 'ExpressRoute' - /// - [JsonProperty(PropertyName = "properties.gatewayType")] - public string GatewayType { get; set; } - - /// - /// Gets or sets the type of this virtual network gateway. Possible - /// values are: 'PolicyBased' and 'RouteBased'. Possible values - /// include: 'PolicyBased', 'RouteBased' - /// - [JsonProperty(PropertyName = "properties.vpnType")] - public string VpnType { get; set; } - - /// - /// Gets or sets whether BGP is enabled for this virtual network - /// gateway or not. - /// - [JsonProperty(PropertyName = "properties.enableBgp")] - public bool? EnableBgp { get; set; } - - /// - /// Gets or sets activeActive flag - /// - [JsonProperty(PropertyName = "properties.activeActive")] - public bool? ActiveActive { get; set; } - - /// - /// Gets or sets the reference of the LocalNetworkGateway resource - /// which represents local network site having default routes. Assign - /// Null value in case of removing existing default site setting. - /// - [JsonProperty(PropertyName = "properties.gatewayDefaultSite")] - public SubResource GatewayDefaultSite { get; set; } - - /// - /// Gets or sets the reference of the VirtualNetworkGatewaySku resource - /// which represents the SKU selected for Virtual network gateway. - /// - [JsonProperty(PropertyName = "properties.sku")] - public VirtualNetworkGatewaySku Sku { get; set; } - - /// - /// Gets or sets the reference of the VpnClientConfiguration resource - /// which represents the P2S VpnClient configurations. - /// - [JsonProperty(PropertyName = "properties.vpnClientConfiguration")] - public VpnClientConfiguration VpnClientConfiguration { get; set; } - - /// - /// Gets or sets virtual network gateway's BGP speaker settings. - /// - [JsonProperty(PropertyName = "properties.bgpSettings")] - public BgpSettings BgpSettings { get; set; } - - /// - /// Gets or sets the resource GUID property of the - /// VirtualNetworkGateway resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets the provisioning state of the VirtualNetworkGateway resource. - /// Possible values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnection.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnection.cs index 606d680e3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnection.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnection.cs @@ -1,213 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A common class for general resource information - /// - [JsonTransformation] - public partial class VirtualNetworkGatewayConnection : Resource - { - /// - /// Initializes a new instance of the VirtualNetworkGatewayConnection - /// class. - /// - public VirtualNetworkGatewayConnection() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VirtualNetworkGatewayConnection - /// class. - /// - /// Gateway connection type. Possible - /// values are: 'Ipsec','Vnet2Vnet','ExpressRoute', and 'VPNClient. - /// Possible values include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', - /// 'VPNClient' - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// The authorizationKey. - /// The routing weight. - /// The IPSec shared key. - /// Virtual network Gateway connection - /// status. Possible values are 'Unknown', 'Connecting', 'Connected' - /// and 'NotConnected'. Possible values include: 'Unknown', - /// 'Connecting', 'Connected', 'NotConnected' - /// Collection of all tunnels' - /// connection health status. - /// The egress bytes transferred - /// in this connection. - /// The ingress bytes transferred - /// in this connection. - /// The reference to peerings resource. - /// EnableBgp flag - /// The resource GUID property of the - /// VirtualNetworkGatewayConnection resource. - /// The provisioning state of the - /// VirtualNetworkGatewayConnection resource. Possible values are: - /// 'Updating', 'Deleting', and 'Failed'. - /// Gets a unique read-only string that changes - /// whenever the resource is updated. - public VirtualNetworkGatewayConnection(VirtualNetworkGateway virtualNetworkGateway1, string connectionType, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string authorizationKey = default(string), VirtualNetworkGateway virtualNetworkGateway2 = default(VirtualNetworkGateway), LocalNetworkGateway localNetworkGateway2 = default(LocalNetworkGateway), int? routingWeight = default(int?), string sharedKey = default(string), string connectionStatus = default(string), IList tunnelConnectionStatus = default(IList), long? egressBytesTransferred = default(long?), long? ingressBytesTransferred = default(long?), SubResource peer = default(SubResource), bool? enableBgp = default(bool?), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) - : base(id, name, type, location, tags) - { - AuthorizationKey = authorizationKey; - VirtualNetworkGateway1 = virtualNetworkGateway1; - VirtualNetworkGateway2 = virtualNetworkGateway2; - LocalNetworkGateway2 = localNetworkGateway2; - ConnectionType = connectionType; - RoutingWeight = routingWeight; - SharedKey = sharedKey; - ConnectionStatus = connectionStatus; - TunnelConnectionStatus = tunnelConnectionStatus; - EgressBytesTransferred = egressBytesTransferred; - IngressBytesTransferred = ingressBytesTransferred; - Peer = peer; - EnableBgp = enableBgp; - ResourceGuid = resourceGuid; - ProvisioningState = provisioningState; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the authorizationKey. - /// - [JsonProperty(PropertyName = "properties.authorizationKey")] - public string AuthorizationKey { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.virtualNetworkGateway1")] - public VirtualNetworkGateway VirtualNetworkGateway1 { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.virtualNetworkGateway2")] - public VirtualNetworkGateway VirtualNetworkGateway2 { get; set; } - - /// - /// - [JsonProperty(PropertyName = "properties.localNetworkGateway2")] - public LocalNetworkGateway LocalNetworkGateway2 { get; set; } - - /// - /// Gets or sets gateway connection type. Possible values are: - /// 'Ipsec','Vnet2Vnet','ExpressRoute', and 'VPNClient. Possible values - /// include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', 'VPNClient' - /// - [JsonProperty(PropertyName = "properties.connectionType")] - public string ConnectionType { get; set; } - - /// - /// Gets or sets the routing weight. - /// - [JsonProperty(PropertyName = "properties.routingWeight")] - public int? RoutingWeight { get; set; } - - /// - /// Gets or sets the IPSec shared key. - /// - [JsonProperty(PropertyName = "properties.sharedKey")] - public string SharedKey { get; set; } - - /// - /// Gets virtual network Gateway connection status. Possible values are - /// 'Unknown', 'Connecting', 'Connected' and 'NotConnected'. Possible - /// values include: 'Unknown', 'Connecting', 'Connected', - /// 'NotConnected' - /// - [JsonProperty(PropertyName = "properties.connectionStatus")] - public string ConnectionStatus { get; private set; } - - /// - /// Gets collection of all tunnels' connection health status. - /// - [JsonProperty(PropertyName = "properties.tunnelConnectionStatus")] - public IList TunnelConnectionStatus { get; private set; } - - /// - /// Gets the egress bytes transferred in this connection. - /// - [JsonProperty(PropertyName = "properties.egressBytesTransferred")] - public long? EgressBytesTransferred { get; private set; } - - /// - /// Gets the ingress bytes transferred in this connection. - /// - [JsonProperty(PropertyName = "properties.ingressBytesTransferred")] - public long? IngressBytesTransferred { get; private set; } - - /// - /// Gets or sets the reference to peerings resource. - /// - [JsonProperty(PropertyName = "properties.peer")] - public SubResource Peer { get; set; } - - /// - /// Gets or sets enableBgp flag - /// - [JsonProperty(PropertyName = "properties.enableBgp")] - public bool? EnableBgp { get; set; } - - /// - /// Gets or sets the resource GUID property of the - /// VirtualNetworkGatewayConnection resource. - /// - [JsonProperty(PropertyName = "properties.resourceGuid")] - public string ResourceGuid { get; set; } - - /// - /// Gets the provisioning state of the VirtualNetworkGatewayConnection - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets a unique read-only string that changes whenever the resource - /// is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (VirtualNetworkGateway1 == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "VirtualNetworkGateway1"); - } - if (ConnectionType == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ConnectionType"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionStatus.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionStatus.cs index 860df1814..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionStatus.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionStatus.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for VirtualNetworkGatewayConnectionStatus. - /// - public static class VirtualNetworkGatewayConnectionStatus - { - public const string Unknown = "Unknown"; - public const string Connecting = "Connecting"; - public const string Connected = "Connected"; - public const string NotConnected = "NotConnected"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionType.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionType.cs index 64073e946..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionType.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayConnectionType.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for VirtualNetworkGatewayConnectionType. - /// - public static class VirtualNetworkGatewayConnectionType - { - public const string IPsec = "IPsec"; - public const string Vnet2Vnet = "Vnet2Vnet"; - public const string ExpressRoute = "ExpressRoute"; - public const string VPNClient = "VPNClient"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayIPConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayIPConfiguration.cs index 5c69d663d..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayIPConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayIPConfiguration.cs @@ -1,107 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// IP configuration for virtual network gateway - /// - [JsonTransformation] - public partial class VirtualNetworkGatewayIPConfiguration : SubResource - { - /// - /// Initializes a new instance of the - /// VirtualNetworkGatewayIPConfiguration class. - /// - public VirtualNetworkGatewayIPConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// VirtualNetworkGatewayIPConfiguration class. - /// - /// Resource ID. - /// The private IP allocation - /// method. Possible values are: 'Static' and 'Dynamic'. Possible - /// values include: 'Static', 'Dynamic' - /// The reference of the subnet resource. - /// The reference of the public IP - /// resource. - /// The provisioning state of the - /// public IP resource. Possible values are: 'Updating', 'Deleting', - /// and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public VirtualNetworkGatewayIPConfiguration(string id = default(string), string privateIPAllocationMethod = default(string), SubResource subnet = default(SubResource), SubResource publicIPAddress = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - PrivateIPAllocationMethod = privateIPAllocationMethod; - Subnet = subnet; - PublicIPAddress = publicIPAddress; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the private IP allocation method. Possible values are: - /// 'Static' and 'Dynamic'. Possible values include: 'Static', - /// 'Dynamic' - /// - [JsonProperty(PropertyName = "properties.privateIPAllocationMethod")] - public string PrivateIPAllocationMethod { get; set; } - - /// - /// Gets or sets the reference of the subnet resource. - /// - [JsonProperty(PropertyName = "properties.subnet")] - public SubResource Subnet { get; set; } - - /// - /// Gets or sets the reference of the public IP resource. - /// - [JsonProperty(PropertyName = "properties.publicIPAddress")] - public SubResource PublicIPAddress { get; set; } - - /// - /// Gets the provisioning state of the public IP resource. Possible - /// values are: 'Updating', 'Deleting', and 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySku.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySku.cs index e7eb7b1f2..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySku.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySku.cs @@ -1,75 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// VirtualNetworkGatewaySku details - /// - public partial class VirtualNetworkGatewaySku - { - /// - /// Initializes a new instance of the VirtualNetworkGatewaySku class. - /// - public VirtualNetworkGatewaySku() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VirtualNetworkGatewaySku class. - /// - /// Gateway SKU name. Possible values are: 'Basic', - /// 'HighPerformance','Standard', and 'UltraPerformance'. Possible - /// values include: 'Basic', 'HighPerformance', 'Standard', - /// 'UltraPerformance' - /// Gateway SKU tier. Possible values are: 'Basic', - /// 'HighPerformance','Standard', and 'UltraPerformance'. Possible - /// values include: 'Basic', 'HighPerformance', 'Standard', - /// 'UltraPerformance' - /// The capacity. - public VirtualNetworkGatewaySku(string name = default(string), string tier = default(string), int? capacity = default(int?)) - { - Name = name; - Tier = tier; - Capacity = capacity; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets gateway SKU name. Possible values are: 'Basic', - /// 'HighPerformance','Standard', and 'UltraPerformance'. Possible - /// values include: 'Basic', 'HighPerformance', 'Standard', - /// 'UltraPerformance' - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets gateway SKU tier. Possible values are: 'Basic', - /// 'HighPerformance','Standard', and 'UltraPerformance'. Possible - /// values include: 'Basic', 'HighPerformance', 'Standard', - /// 'UltraPerformance' - /// - [JsonProperty(PropertyName = "tier")] - public string Tier { get; set; } - - /// - /// Gets or sets the capacity. - /// - [JsonProperty(PropertyName = "capacity")] - public int? Capacity { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuName.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuName.cs index faefee44a..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuName.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuName.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for VirtualNetworkGatewaySkuName. - /// - public static class VirtualNetworkGatewaySkuName - { - public const string Basic = "Basic"; - public const string HighPerformance = "HighPerformance"; - public const string Standard = "Standard"; - public const string UltraPerformance = "UltraPerformance"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuTier.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuTier.cs index aa51eb037..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuTier.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewaySkuTier.cs @@ -1,20 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for VirtualNetworkGatewaySkuTier. - /// - public static class VirtualNetworkGatewaySkuTier - { - public const string Basic = "Basic"; - public const string HighPerformance = "HighPerformance"; - public const string Standard = "Standard"; - public const string UltraPerformance = "UltraPerformance"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayType.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayType.cs index 3cc5f2707..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayType.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkGatewayType.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for VirtualNetworkGatewayType. - /// - public static class VirtualNetworkGatewayType - { - public const string Vpn = "Vpn"; - public const string ExpressRoute = "ExpressRoute"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeering.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeering.cs index 39c276de7..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeering.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeering.cs @@ -1,146 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Peerings in a virtual network resource. - /// - [JsonTransformation] - public partial class VirtualNetworkPeering : SubResource - { - /// - /// Initializes a new instance of the VirtualNetworkPeering class. - /// - public VirtualNetworkPeering() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VirtualNetworkPeering class. - /// - /// Resource ID. - /// Whether the VMs in the - /// linked virtual network space would be able to access all the VMs in - /// local Virtual network space. - /// Whether the forwarded traffic - /// from the VMs in the remote virtual network will be - /// allowed/disallowed. - /// If gateway links can be used in - /// remote virtual networking to link to this virtual network. - /// If remote gateways can be used on - /// this virtual network. If the flag is set to true, and - /// allowGatewayTransit on remote peering is also true, virtual network - /// will use gateways of remote virtual network for transit. Only one - /// peering can have this flag set to true. This flag cannot be set if - /// virtual network already has a gateway. - /// The reference of the remote - /// virtual network. - /// The status of the virtual network - /// peering. Possible values are 'Initiated', 'Connected', and - /// 'Disconnected'. Possible values include: 'Initiated', 'Connected', - /// 'Disconnected' - /// The provisioning state of the - /// resource. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public VirtualNetworkPeering(string id = default(string), bool? allowVirtualNetworkAccess = default(bool?), bool? allowForwardedTraffic = default(bool?), bool? allowGatewayTransit = default(bool?), bool? useRemoteGateways = default(bool?), SubResource remoteVirtualNetwork = default(SubResource), string peeringState = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - AllowVirtualNetworkAccess = allowVirtualNetworkAccess; - AllowForwardedTraffic = allowForwardedTraffic; - AllowGatewayTransit = allowGatewayTransit; - UseRemoteGateways = useRemoteGateways; - RemoteVirtualNetwork = remoteVirtualNetwork; - PeeringState = peeringState; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets whether the VMs in the linked virtual network space - /// would be able to access all the VMs in local Virtual network space. - /// - [JsonProperty(PropertyName = "properties.allowVirtualNetworkAccess")] - public bool? AllowVirtualNetworkAccess { get; set; } - - /// - /// Gets or sets whether the forwarded traffic from the VMs in the - /// remote virtual network will be allowed/disallowed. - /// - [JsonProperty(PropertyName = "properties.allowForwardedTraffic")] - public bool? AllowForwardedTraffic { get; set; } - - /// - /// Gets or sets if gateway links can be used in remote virtual - /// networking to link to this virtual network. - /// - [JsonProperty(PropertyName = "properties.allowGatewayTransit")] - public bool? AllowGatewayTransit { get; set; } - - /// - /// Gets or sets if remote gateways can be used on this virtual - /// network. If the flag is set to true, and allowGatewayTransit on - /// remote peering is also true, virtual network will use gateways of - /// remote virtual network for transit. Only one peering can have this - /// flag set to true. This flag cannot be set if virtual network - /// already has a gateway. - /// - [JsonProperty(PropertyName = "properties.useRemoteGateways")] - public bool? UseRemoteGateways { get; set; } - - /// - /// Gets or sets the reference of the remote virtual network. - /// - [JsonProperty(PropertyName = "properties.remoteVirtualNetwork")] - public SubResource RemoteVirtualNetwork { get; set; } - - /// - /// Gets or sets the status of the virtual network peering. Possible - /// values are 'Initiated', 'Connected', and 'Disconnected'. Possible - /// values include: 'Initiated', 'Connected', 'Disconnected' - /// - [JsonProperty(PropertyName = "properties.peeringState")] - public string PeeringState { get; set; } - - /// - /// Gets or sets the provisioning state of the resource. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeeringState.cs b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeeringState.cs index 8996670e3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeeringState.cs +++ b/Samples/test/end-to-end/network/Client/Models/VirtualNetworkPeeringState.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for VirtualNetworkPeeringState. - /// - public static class VirtualNetworkPeeringState - { - public const string Initiated = "Initiated"; - public const string Connected = "Connected"; - public const string Disconnected = "Disconnected"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VpnClientConfiguration.cs b/Samples/test/end-to-end/network/Client/Models/VpnClientConfiguration.cs index 05f0b1207..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VpnClientConfiguration.cs +++ b/Samples/test/end-to-end/network/Client/Models/VpnClientConfiguration.cs @@ -1,72 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// VpnClientConfiguration for P2S client. - /// - public partial class VpnClientConfiguration - { - /// - /// Initializes a new instance of the VpnClientConfiguration class. - /// - public VpnClientConfiguration() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VpnClientConfiguration class. - /// - /// The reference of the address - /// space resource which represents Address space for P2S - /// VpnClient. - /// VpnClientRootCertificate - /// for virtual network gateway. - /// VpnClientRevokedCertificate for - /// Virtual network gateway. - public VpnClientConfiguration(AddressSpace vpnClientAddressPool = default(AddressSpace), IList vpnClientRootCertificates = default(IList), IList vpnClientRevokedCertificates = default(IList)) - { - VpnClientAddressPool = vpnClientAddressPool; - VpnClientRootCertificates = vpnClientRootCertificates; - VpnClientRevokedCertificates = vpnClientRevokedCertificates; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the reference of the address space resource which - /// represents Address space for P2S VpnClient. - /// - [JsonProperty(PropertyName = "vpnClientAddressPool")] - public AddressSpace VpnClientAddressPool { get; set; } - - /// - /// Gets or sets vpnClientRootCertificate for virtual network gateway. - /// - [JsonProperty(PropertyName = "vpnClientRootCertificates")] - public IList VpnClientRootCertificates { get; set; } - - /// - /// Gets or sets vpnClientRevokedCertificate for Virtual network - /// gateway. - /// - [JsonProperty(PropertyName = "vpnClientRevokedCertificates")] - public IList VpnClientRevokedCertificates { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VpnClientParameters.cs b/Samples/test/end-to-end/network/Client/Models/VpnClientParameters.cs index 5c07c5c9f..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VpnClientParameters.cs +++ b/Samples/test/end-to-end/network/Client/Models/VpnClientParameters.cs @@ -1,64 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// VpnClientParameters - /// - public partial class VpnClientParameters - { - /// - /// Initializes a new instance of the VpnClientParameters class. - /// - public VpnClientParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VpnClientParameters class. - /// - /// VPN client Processor - /// Architecture. Possible values are: 'AMD64' and 'X86'. Possible - /// values include: 'Amd64', 'X86' - public VpnClientParameters(string processorArchitecture) - { - ProcessorArchitecture = processorArchitecture; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets VPN client Processor Architecture. Possible values - /// are: 'AMD64' and 'X86'. Possible values include: 'Amd64', 'X86' - /// - [JsonProperty(PropertyName = "ProcessorArchitecture")] - public string ProcessorArchitecture { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (ProcessorArchitecture == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ProcessorArchitecture"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VpnClientRevokedCertificate.cs b/Samples/test/end-to-end/network/Client/Models/VpnClientRevokedCertificate.cs index e1c6c658d..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VpnClientRevokedCertificate.cs +++ b/Samples/test/end-to-end/network/Client/Models/VpnClientRevokedCertificate.cs @@ -1,88 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// VPN client revoked certificate of virtual network gateway. - /// - [JsonTransformation] - public partial class VpnClientRevokedCertificate : SubResource - { - /// - /// Initializes a new instance of the VpnClientRevokedCertificate - /// class. - /// - public VpnClientRevokedCertificate() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VpnClientRevokedCertificate - /// class. - /// - /// Resource ID. - /// The revoked VPN client certificate - /// thumbprint. - /// The provisioning state of the VPN - /// client revoked certificate resource. Possible values are: - /// 'Updating', 'Deleting', and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public VpnClientRevokedCertificate(string id = default(string), string thumbprint = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - Thumbprint = thumbprint; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the revoked VPN client certificate thumbprint. - /// - [JsonProperty(PropertyName = "properties.thumbprint")] - public string Thumbprint { get; set; } - - /// - /// Gets the provisioning state of the VPN client revoked certificate - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VpnClientRootCertificate.cs b/Samples/test/end-to-end/network/Client/Models/VpnClientRootCertificate.cs index e0c4cb0a3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VpnClientRootCertificate.cs +++ b/Samples/test/end-to-end/network/Client/Models/VpnClientRootCertificate.cs @@ -1,98 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// VPN client root certificate of virtual network gateway - /// - [JsonTransformation] - public partial class VpnClientRootCertificate : SubResource - { - /// - /// Initializes a new instance of the VpnClientRootCertificate class. - /// - public VpnClientRootCertificate() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the VpnClientRootCertificate class. - /// - /// The certificate public data. - /// Resource ID. - /// The provisioning state of the VPN - /// client root certificate resource. Possible values are: 'Updating', - /// 'Deleting', and 'Failed'. - /// The name of the resource that is unique within a - /// resource group. This name can be used to access the - /// resource. - /// A unique read-only string that changes whenever - /// the resource is updated. - public VpnClientRootCertificate(string publicCertData, string id = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) - : base(id) - { - PublicCertData = publicCertData; - ProvisioningState = provisioningState; - Name = name; - Etag = etag; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the certificate public data. - /// - [JsonProperty(PropertyName = "properties.publicCertData")] - public string PublicCertData { get; set; } - - /// - /// Gets the provisioning state of the VPN client root certificate - /// resource. Possible values are: 'Updating', 'Deleting', and - /// 'Failed'. - /// - [JsonProperty(PropertyName = "properties.provisioningState")] - public string ProvisioningState { get; private set; } - - /// - /// Gets or sets the name of the resource that is unique within a - /// resource group. This name can be used to access the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets a unique read-only string that changes whenever the - /// resource is updated. - /// - [JsonProperty(PropertyName = "etag")] - public string Etag { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (PublicCertData == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "PublicCertData"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/Models/VpnType.cs b/Samples/test/end-to-end/network/Client/Models/VpnType.cs index d59318207..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/Models/VpnType.cs +++ b/Samples/test/end-to-end/network/Client/Models/VpnType.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway.Models -{ - - /// - /// Defines values for VpnType. - /// - public static class VpnType - { - public const string PolicyBased = "PolicyBased"; - public const string RouteBased = "RouteBased"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkClient.cs b/Samples/test/end-to-end/network/Client/NetworkClient.cs index b4b9395ca..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkClient.cs +++ b/Samples/test/end-to-end/network/Client/NetworkClient.cs @@ -1,657 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// The Microsoft Azure Network management API provides a RESTful set of - /// web services that interact with Microsoft Azure Networks service to - /// manage your network resources. The API has entities that capture the - /// relationship between an end user and the Microsoft Azure Networks - /// service. - /// - public partial class NetworkClient : ServiceClient, INetworkClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// The subscription credentials which uniquely identify the Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. - /// - public string SubscriptionId { get; set; } - - /// - /// Client API version. - /// - public string ApiVersion { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Gets the IApplicationGatewaysOperations. - /// - public virtual IApplicationGatewaysOperations ApplicationGateways { get; private set; } - - /// - /// Gets the IExpressRouteCircuitAuthorizationsOperations. - /// - public virtual IExpressRouteCircuitAuthorizationsOperations ExpressRouteCircuitAuthorizations { get; private set; } - - /// - /// Gets the IExpressRouteCircuitPeeringsOperations. - /// - public virtual IExpressRouteCircuitPeeringsOperations ExpressRouteCircuitPeerings { get; private set; } - - /// - /// Gets the IExpressRouteCircuitsOperations. - /// - public virtual IExpressRouteCircuitsOperations ExpressRouteCircuits { get; private set; } - - /// - /// Gets the IExpressRouteServiceProvidersOperations. - /// - public virtual IExpressRouteServiceProvidersOperations ExpressRouteServiceProviders { get; private set; } - - /// - /// Gets the ILoadBalancersOperations. - /// - public virtual ILoadBalancersOperations LoadBalancers { get; private set; } - - /// - /// Gets the INetworkInterfacesOperations. - /// - public virtual INetworkInterfacesOperations NetworkInterfaces { get; private set; } - - /// - /// Gets the INetworkSecurityGroupsOperations. - /// - public virtual INetworkSecurityGroupsOperations NetworkSecurityGroups { get; private set; } - - /// - /// Gets the ISecurityRulesOperations. - /// - public virtual ISecurityRulesOperations SecurityRules { get; private set; } - - /// - /// Gets the INetworkWatchersOperations. - /// - public virtual INetworkWatchersOperations NetworkWatchers { get; private set; } - - /// - /// Gets the IPacketCapturesOperations. - /// - public virtual IPacketCapturesOperations PacketCaptures { get; private set; } - - /// - /// Gets the IPublicIPAddressesOperations. - /// - public virtual IPublicIPAddressesOperations PublicIPAddresses { get; private set; } - - /// - /// Gets the IRouteFiltersOperations. - /// - public virtual IRouteFiltersOperations RouteFilters { get; private set; } - - /// - /// Gets the IRouteFilterRulesOperations. - /// - public virtual IRouteFilterRulesOperations RouteFilterRules { get; private set; } - - /// - /// Gets the IRouteTablesOperations. - /// - public virtual IRouteTablesOperations RouteTables { get; private set; } - - /// - /// Gets the IRoutesOperations. - /// - public virtual IRoutesOperations Routes { get; private set; } - - /// - /// Gets the IBgpServiceCommunitiesOperations. - /// - public virtual IBgpServiceCommunitiesOperations BgpServiceCommunities { get; private set; } - - /// - /// Gets the IUsagesOperations. - /// - public virtual IUsagesOperations Usages { get; private set; } - - /// - /// Gets the IVirtualNetworksOperations. - /// - public virtual IVirtualNetworksOperations VirtualNetworks { get; private set; } - - /// - /// Gets the ISubnetsOperations. - /// - public virtual ISubnetsOperations Subnets { get; private set; } - - /// - /// Gets the IVirtualNetworkPeeringsOperations. - /// - public virtual IVirtualNetworkPeeringsOperations VirtualNetworkPeerings { get; private set; } - - /// - /// Gets the IVirtualNetworkGatewaysOperations. - /// - public virtual IVirtualNetworkGatewaysOperations VirtualNetworkGateways { get; private set; } - - /// - /// Gets the IVirtualNetworkGatewayConnectionsOperations. - /// - public virtual IVirtualNetworkGatewayConnectionsOperations VirtualNetworkGatewayConnections { get; private set; } - - /// - /// Gets the ILocalNetworkGatewaysOperations. - /// - public virtual ILocalNetworkGatewaysOperations LocalNetworkGateways { get; private set; } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected NetworkClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected NetworkClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected NetworkClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected NetworkClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public NetworkClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public NetworkClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public NetworkClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the NetworkClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public NetworkClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - ApplicationGateways = new ApplicationGatewaysOperations(this); - ExpressRouteCircuitAuthorizations = new ExpressRouteCircuitAuthorizationsOperations(this); - ExpressRouteCircuitPeerings = new ExpressRouteCircuitPeeringsOperations(this); - ExpressRouteCircuits = new ExpressRouteCircuitsOperations(this); - ExpressRouteServiceProviders = new ExpressRouteServiceProvidersOperations(this); - LoadBalancers = new LoadBalancersOperations(this); - NetworkInterfaces = new NetworkInterfacesOperations(this); - NetworkSecurityGroups = new NetworkSecurityGroupsOperations(this); - SecurityRules = new SecurityRulesOperations(this); - NetworkWatchers = new NetworkWatchersOperations(this); - PacketCaptures = new PacketCapturesOperations(this); - PublicIPAddresses = new PublicIPAddressesOperations(this); - RouteFilters = new RouteFiltersOperations(this); - RouteFilterRules = new RouteFilterRulesOperations(this); - RouteTables = new RouteTablesOperations(this); - Routes = new RoutesOperations(this); - BgpServiceCommunities = new BgpServiceCommunitiesOperations(this); - Usages = new UsagesOperations(this); - VirtualNetworks = new VirtualNetworksOperations(this); - Subnets = new SubnetsOperations(this); - VirtualNetworkPeerings = new VirtualNetworkPeeringsOperations(this); - VirtualNetworkGateways = new VirtualNetworkGatewaysOperations(this); - VirtualNetworkGatewayConnections = new VirtualNetworkGatewayConnectionsOperations(this); - LocalNetworkGateways = new LocalNetworkGatewaysOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2016-12-01"; - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - /// - /// Checks whether a domain name in the cloudapp.net zone is available for use. - /// - /// - /// The location of the domain name. - /// - /// - /// The domain name to be verified. It must conform to the following regular - /// expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckDnsNameAvailabilityWithHttpMessagesAsync(string location, string domainNameLabel = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "location"); - } - if (ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); - } - if (SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("location", location); - tracingParameters.Add("domainNameLabel", domainNameLabel); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckDnsNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability").ToString(); - _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(SubscriptionId)); - List _queryParameters = new List(); - if (domainNameLabel != null) - { - _queryParameters.Add(string.Format("domainNameLabel={0}", System.Uri.EscapeDataString(domainNameLabel))); - } - if (ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkClientExtensions.cs b/Samples/test/end-to-end/network/Client/NetworkClientExtensions.cs index 4d6f4e818..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkClientExtensions.cs +++ b/Samples/test/end-to-end/network/Client/NetworkClientExtensions.cs @@ -1,63 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for NetworkClient. - /// - public static partial class NetworkClientExtensions - { - /// - /// Checks whether a domain name in the cloudapp.net zone is available for use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The location of the domain name. - /// - /// - /// The domain name to be verified. It must conform to the following regular - /// expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. - /// - public static DnsNameAvailabilityResult CheckDnsNameAvailability(this INetworkClient operations, string location, string domainNameLabel = default(string)) - { - return operations.CheckDnsNameAvailabilityAsync(location, domainNameLabel).GetAwaiter().GetResult(); - } - - /// - /// Checks whether a domain name in the cloudapp.net zone is available for use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The location of the domain name. - /// - /// - /// The domain name to be verified. It must conform to the following regular - /// expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. - /// - /// - /// The cancellation token. - /// - public static async Task CheckDnsNameAvailabilityAsync(this INetworkClient operations, string location, string domainNameLabel = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckDnsNameAvailabilityWithHttpMessagesAsync(location, domainNameLabel, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkInterfacesOperations.cs b/Samples/test/end-to-end/network/Client/NetworkInterfacesOperations.cs index cc914ecde..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkInterfacesOperations.cs +++ b/Samples/test/end-to-end/network/Client/NetworkInterfacesOperations.cs @@ -1,2816 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// NetworkInterfacesOperations operations. - /// - internal partial class NetworkInterfacesOperations : IServiceOperations, INetworkInterfacesOperations - { - /// - /// Initializes a new instance of the NetworkInterfacesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal NetworkInterfacesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets information about the specified network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkInterfaceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkInterfaceName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkInterfaceName", networkInterfaceName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkInterfaceName}", System.Uri.EscapeDataString(networkInterfaceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/networkInterfaces").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetEffectiveRouteTableWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetEffectiveRouteTableWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> ListEffectiveNetworkSecurityGroupsWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginListEffectiveNetworkSecurityGroupsWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets information about all network interfaces in a virtual machine in a - /// virtual machine scale set. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListVirtualMachineScaleSetVMNetworkInterfacesWithHttpMessagesAsync(string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualMachineScaleSetName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineScaleSetName"); - } - if (virtualmachineIndex == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualmachineIndex"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2016-09-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualMachineScaleSetName", virtualMachineScaleSetName); - tracingParameters.Add("virtualmachineIndex", virtualmachineIndex); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListVirtualMachineScaleSetVMNetworkInterfaces", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualMachineScaleSetName}", System.Uri.EscapeDataString(virtualMachineScaleSetName)); - _url = _url.Replace("{virtualmachineIndex}", System.Uri.EscapeDataString(virtualmachineIndex)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListVirtualMachineScaleSetNetworkInterfacesWithHttpMessagesAsync(string resourceGroupName, string virtualMachineScaleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualMachineScaleSetName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineScaleSetName"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2016-09-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualMachineScaleSetName", virtualMachineScaleSetName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListVirtualMachineScaleSetNetworkInterfaces", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/networkInterfaces").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualMachineScaleSetName}", System.Uri.EscapeDataString(virtualMachineScaleSetName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Get the specified network interface in a virtual machine scale set. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetVirtualMachineScaleSetNetworkInterfaceWithHttpMessagesAsync(string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex, string networkInterfaceName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualMachineScaleSetName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineScaleSetName"); - } - if (virtualmachineIndex == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualmachineIndex"); - } - if (networkInterfaceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkInterfaceName"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - string apiVersion = "2016-09-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualMachineScaleSetName", virtualMachineScaleSetName); - tracingParameters.Add("virtualmachineIndex", virtualmachineIndex); - tracingParameters.Add("networkInterfaceName", networkInterfaceName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetVirtualMachineScaleSetNetworkInterface", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualMachineScaleSetName}", System.Uri.EscapeDataString(virtualMachineScaleSetName)); - _url = _url.Replace("{virtualmachineIndex}", System.Uri.EscapeDataString(virtualmachineIndex)); - _url = _url.Replace("{networkInterfaceName}", System.Uri.EscapeDataString(networkInterfaceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkInterfaceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkInterfaceName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkInterfaceName", networkInterfaceName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkInterfaceName}", System.Uri.EscapeDataString(networkInterfaceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 202 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkInterfaceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkInterfaceName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkInterfaceName", networkInterfaceName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkInterfaceName}", System.Uri.EscapeDataString(networkInterfaceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetEffectiveRouteTableWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkInterfaceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkInterfaceName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkInterfaceName", networkInterfaceName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetEffectiveRouteTable", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}/effectiveRouteTable").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkInterfaceName}", System.Uri.EscapeDataString(networkInterfaceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginListEffectiveNetworkSecurityGroupsWithHttpMessagesAsync(string resourceGroupName, string networkInterfaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkInterfaceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkInterfaceName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkInterfaceName", networkInterfaceName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginListEffectiveNetworkSecurityGroups", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}/effectiveNetworkSecurityGroups").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkInterfaceName}", System.Uri.EscapeDataString(networkInterfaceName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets information about all network interfaces in a virtual machine in a - /// virtual machine scale set. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListVirtualMachineScaleSetVMNetworkInterfacesNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListVirtualMachineScaleSetVMNetworkInterfacesNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListVirtualMachineScaleSetNetworkInterfacesNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListVirtualMachineScaleSetNetworkInterfacesNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkInterfacesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/NetworkInterfacesOperationsExtensions.cs index 489342102..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkInterfacesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/NetworkInterfacesOperationsExtensions.cs @@ -1,739 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for NetworkInterfacesOperations. - /// - public static partial class NetworkInterfacesOperationsExtensions - { - /// - /// Deletes the specified network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - public static void Delete(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName) - { - operations.DeleteAsync(resourceGroupName, networkInterfaceName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets information about the specified network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - public static NetworkInterface Get(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, networkInterfaceName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets information about the specified network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface operation. - /// - public static NetworkInterface CreateOrUpdate(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, NetworkInterface parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, networkInterfaceName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this INetworkInterfacesOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this INetworkInterfacesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this INetworkInterfacesOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this INetworkInterfacesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - public static EffectiveRouteListResult GetEffectiveRouteTable(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName) - { - return operations.GetEffectiveRouteTableAsync(resourceGroupName, networkInterfaceName).GetAwaiter().GetResult(); - } - - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The cancellation token. - /// - public static async Task GetEffectiveRouteTableAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetEffectiveRouteTableWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - public static EffectiveNetworkSecurityGroupListResult ListEffectiveNetworkSecurityGroups(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName) - { - return operations.ListEffectiveNetworkSecurityGroupsAsync(resourceGroupName, networkInterfaceName).GetAwaiter().GetResult(); - } - - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The cancellation token. - /// - public static async Task ListEffectiveNetworkSecurityGroupsAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListEffectiveNetworkSecurityGroupsWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets information about all network interfaces in a virtual machine in a - /// virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - public static IPage ListVirtualMachineScaleSetVMNetworkInterfaces(this INetworkInterfacesOperations operations, string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex) - { - return operations.ListVirtualMachineScaleSetVMNetworkInterfacesAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex).GetAwaiter().GetResult(); - } - - /// - /// Gets information about all network interfaces in a virtual machine in a - /// virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - /// - /// The cancellation token. - /// - public static async Task> ListVirtualMachineScaleSetVMNetworkInterfacesAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListVirtualMachineScaleSetVMNetworkInterfacesWithHttpMessagesAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - public static IPage ListVirtualMachineScaleSetNetworkInterfaces(this INetworkInterfacesOperations operations, string resourceGroupName, string virtualMachineScaleSetName) - { - return operations.ListVirtualMachineScaleSetNetworkInterfacesAsync(resourceGroupName, virtualMachineScaleSetName).GetAwaiter().GetResult(); - } - - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The cancellation token. - /// - public static async Task> ListVirtualMachineScaleSetNetworkInterfacesAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string virtualMachineScaleSetName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListVirtualMachineScaleSetNetworkInterfacesWithHttpMessagesAsync(resourceGroupName, virtualMachineScaleSetName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Get the specified network interface in a virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - public static NetworkInterface GetVirtualMachineScaleSetNetworkInterface(this INetworkInterfacesOperations operations, string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex, string networkInterfaceName, string expand = default(string)) - { - return operations.GetVirtualMachineScaleSetNetworkInterfaceAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, expand).GetAwaiter().GetResult(); - } - - /// - /// Get the specified network interface in a virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual machine scale set. - /// - /// - /// The virtual machine index. - /// - /// - /// The name of the network interface. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetVirtualMachineScaleSetNetworkInterfaceAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string virtualMachineScaleSetName, string virtualmachineIndex, string networkInterfaceName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetVirtualMachineScaleSetNetworkInterfaceWithHttpMessagesAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - public static void BeginDelete(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName) - { - operations.BeginDeleteAsync(resourceGroupName, networkInterfaceName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface operation. - /// - public static NetworkInterface BeginCreateOrUpdate(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, NetworkInterface parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, networkInterfaceName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// Parameters supplied to the create or update network interface operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - public static EffectiveRouteListResult BeginGetEffectiveRouteTable(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName) - { - return operations.BeginGetEffectiveRouteTableAsync(resourceGroupName, networkInterfaceName).GetAwaiter().GetResult(); - } - - /// - /// Gets all route tables applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetEffectiveRouteTableAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetEffectiveRouteTableWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - public static EffectiveNetworkSecurityGroupListResult BeginListEffectiveNetworkSecurityGroups(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName) - { - return operations.BeginListEffectiveNetworkSecurityGroupsAsync(resourceGroupName, networkInterfaceName).GetAwaiter().GetResult(); - } - - /// - /// Gets all network security groups applied to a network interface. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network interface. - /// - /// - /// The cancellation token. - /// - public static async Task BeginListEffectiveNetworkSecurityGroupsAsync(this INetworkInterfacesOperations operations, string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginListEffectiveNetworkSecurityGroupsWithHttpMessagesAsync(resourceGroupName, networkInterfaceName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this INetworkInterfacesOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all network interfaces in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this INetworkInterfacesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this INetworkInterfacesOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all network interfaces in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this INetworkInterfacesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets information about all network interfaces in a virtual machine in a - /// virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListVirtualMachineScaleSetVMNetworkInterfacesNext(this INetworkInterfacesOperations operations, string nextPageLink) - { - return operations.ListVirtualMachineScaleSetVMNetworkInterfacesNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets information about all network interfaces in a virtual machine in a - /// virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListVirtualMachineScaleSetVMNetworkInterfacesNextAsync(this INetworkInterfacesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListVirtualMachineScaleSetVMNetworkInterfacesNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListVirtualMachineScaleSetNetworkInterfacesNext(this INetworkInterfacesOperations operations, string nextPageLink) - { - return operations.ListVirtualMachineScaleSetNetworkInterfacesNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all network interfaces in a virtual machine scale set. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListVirtualMachineScaleSetNetworkInterfacesNextAsync(this INetworkInterfacesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListVirtualMachineScaleSetNetworkInterfacesNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperations.cs b/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperations.cs index b2bece5f9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperations.cs +++ b/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperations.cs @@ -1,1419 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// NetworkSecurityGroupsOperations operations. - /// - internal partial class NetworkSecurityGroupsOperations : IServiceOperations, INetworkSecurityGroupsOperations - { - /// - /// Initializes a new instance of the NetworkSecurityGroupsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal NetworkSecurityGroupsOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkSecurityGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkSecurityGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkSecurityGroupName", networkSecurityGroupName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkSecurityGroupName}", System.Uri.EscapeDataString(networkSecurityGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a network security group in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all network security groups in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityGroups").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkSecurityGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkSecurityGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkSecurityGroupName", networkSecurityGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkSecurityGroupName}", System.Uri.EscapeDataString(networkSecurityGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a network security group in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkSecurityGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkSecurityGroupName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkSecurityGroupName", networkSecurityGroupName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkSecurityGroupName}", System.Uri.EscapeDataString(networkSecurityGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network security groups in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperationsExtensions.cs index 3e02913f1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/NetworkSecurityGroupsOperationsExtensions.cs @@ -1,371 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for NetworkSecurityGroupsOperations. - /// - public static partial class NetworkSecurityGroupsOperationsExtensions - { - /// - /// Deletes the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - public static void Delete(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName) - { - operations.DeleteAsync(resourceGroupName, networkSecurityGroupName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Expands referenced resources. - /// - public static NetworkSecurityGroup Get(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, networkSecurityGroupName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a network security group in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - public static NetworkSecurityGroup CreateOrUpdate(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, networkSecurityGroupName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a network security group in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network security groups in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this INetworkSecurityGroupsOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all network security groups in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this INetworkSecurityGroupsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this INetworkSecurityGroupsOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this INetworkSecurityGroupsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - public static void BeginDelete(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName) - { - operations.BeginDeleteAsync(resourceGroupName, networkSecurityGroupName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a network security group in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - public static NetworkSecurityGroup BeginCreateOrUpdate(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, networkSecurityGroupName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a network security group in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Parameters supplied to the create or update network security group - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this INetworkSecurityGroupsOperations operations, string resourceGroupName, string networkSecurityGroupName, NetworkSecurityGroup parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network security groups in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this INetworkSecurityGroupsOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all network security groups in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this INetworkSecurityGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this INetworkSecurityGroupsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all network security groups in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this INetworkSecurityGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkWatchersOperations.cs b/Samples/test/end-to-end/network/Client/NetworkWatchersOperations.cs index 9300778b9..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkWatchersOperations.cs +++ b/Samples/test/end-to-end/network/Client/NetworkWatchersOperations.cs @@ -1,3051 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// NetworkWatchersOperations operations. - /// - internal partial class NetworkWatchersOperations : IServiceOperations, INetworkWatchersOperations - { - /// - /// Initializes a new instance of the NetworkWatchersOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal NetworkWatchersOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Creates or updates a network watcher in the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the network watcher resource. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, NetworkWatcher parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the specified network watcher by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkWatcherName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all network watchers by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all network watchers by subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/networkWatchers").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the current network topology by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the representation of topology. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetTopologyWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, TopologyParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetTopology", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/topology").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Verify IP flow from the specified VM to a location given the currently - /// configured NSG rules. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> VerifyIPFlowWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginVerifyIPFlowWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetNextHopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, NextHopParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetNextHopWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the configured and effective security group rules on the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetVMSecurityRulesWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetVMSecurityRulesWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetTroubleshootingWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetTroubleshootingWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get the last completed troubleshooting result on a specified resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting result. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetTroubleshootingResultWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetTroubleshootingResultWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Configures flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> SetFlowLogConfigurationWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogInformation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginSetFlowLogConfigurationWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetFlowLogStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetFlowLogStatusWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Verify IP flow from the specified VM to a location given the currently - /// configured NSG rules. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginVerifyIPFlowWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginVerifyIPFlow", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/ipFlowVerify").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetNextHopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, NextHopParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetNextHop", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/nextHop").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets the configured and effective security group rules on the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetVMSecurityRulesWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetVMSecurityRules", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetTroubleshootingWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetTroubleshooting", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/troubleshoot").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Get the last completed troubleshooting result on a specified resource - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting result. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetTroubleshootingResultWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetTroubleshootingResult", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryTroubleshootResult").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Configures flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginSetFlowLogConfigurationWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogInformation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginSetFlowLogConfiguration", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/configureFlowLog").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetFlowLogStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetFlowLogStatus", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryFlowLogStatus").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/NetworkWatchersOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/NetworkWatchersOperationsExtensions.cs index 2cd0a09ff..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/NetworkWatchersOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/NetworkWatchersOperationsExtensions.cs @@ -1,939 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for NetworkWatchersOperations. - /// - public static partial class NetworkWatchersOperationsExtensions - { - /// - /// Creates or updates a network watcher in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the network watcher resource. - /// - public static NetworkWatcher CreateOrUpdate(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, NetworkWatcher parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a network watcher in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the network watcher resource. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, NetworkWatcher parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the specified network watcher by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - public static NetworkWatcher Get(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName) - { - return operations.GetAsync(resourceGroupName, networkWatcherName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified network watcher by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkWatcherName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - public static void Delete(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName) - { - operations.DeleteAsync(resourceGroupName, networkWatcherName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkWatcherName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets all network watchers by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IEnumerable List(this INetworkWatchersOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all network watchers by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this INetworkWatchersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all network watchers by subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IEnumerable ListAll(this INetworkWatchersOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all network watchers by subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this INetworkWatchersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the current network topology by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the representation of topology. - /// - public static Topology GetTopology(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, TopologyParameters parameters) - { - return operations.GetTopologyAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Gets the current network topology by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the representation of topology. - /// - /// - /// The cancellation token. - /// - public static async Task GetTopologyAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, TopologyParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetTopologyWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Verify IP flow from the specified VM to a location given the currently - /// configured NSG rules. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - public static VerificationIPFlowResult VerifyIPFlow(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters) - { - return operations.VerifyIPFlowAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Verify IP flow from the specified VM to a location given the currently - /// configured NSG rules. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - /// - /// The cancellation token. - /// - public static async Task VerifyIPFlowAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.VerifyIPFlowWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - public static NextHopResult GetNextHop(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, NextHopParameters parameters) - { - return operations.GetNextHopAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - /// - /// The cancellation token. - /// - public static async Task GetNextHopAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, NextHopParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetNextHopWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the configured and effective security group rules on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - public static SecurityGroupViewResult GetVMSecurityRules(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters) - { - return operations.GetVMSecurityRulesAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Gets the configured and effective security group rules on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - /// - /// The cancellation token. - /// - public static async Task GetVMSecurityRulesAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetVMSecurityRulesWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - public static TroubleshootingResult GetTroubleshooting(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters) - { - return operations.GetTroubleshootingAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - /// - /// The cancellation token. - /// - public static async Task GetTroubleshootingAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetTroubleshootingWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Get the last completed troubleshooting result on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting result. - /// - public static TroubleshootingResult GetTroubleshootingResult(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters) - { - return operations.GetTroubleshootingResultAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Get the last completed troubleshooting result on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting result. - /// - /// - /// The cancellation token. - /// - public static async Task GetTroubleshootingResultAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetTroubleshootingResultWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Configures flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - public static FlowLogInformation SetFlowLogConfiguration(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogInformation parameters) - { - return operations.SetFlowLogConfigurationAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Configures flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - /// - /// The cancellation token. - /// - public static async Task SetFlowLogConfigurationAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogInformation parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.SetFlowLogConfigurationWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - public static FlowLogInformation GetFlowLogStatus(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters) - { - return operations.GetFlowLogStatusAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - /// - /// The cancellation token. - /// - public static async Task GetFlowLogStatusAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetFlowLogStatusWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - public static void BeginDelete(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName) - { - operations.BeginDeleteAsync(resourceGroupName, networkWatcherName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network watcher resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkWatcherName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Verify IP flow from the specified VM to a location given the currently - /// configured NSG rules. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - public static VerificationIPFlowResult BeginVerifyIPFlow(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters) - { - return operations.BeginVerifyIPFlowAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Verify IP flow from the specified VM to a location given the currently - /// configured NSG rules. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the IP flow to be verified. - /// - /// - /// The cancellation token. - /// - public static async Task BeginVerifyIPFlowAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginVerifyIPFlowWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - public static NextHopResult BeginGetNextHop(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, NextHopParameters parameters) - { - return operations.BeginGetNextHopAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Gets the next hop from the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the source and destination endpoint. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetNextHopAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, NextHopParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetNextHopWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the configured and effective security group rules on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - public static SecurityGroupViewResult BeginGetVMSecurityRules(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters) - { - return operations.BeginGetVMSecurityRulesAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Gets the configured and effective security group rules on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// Parameters that define the VM to check security groups for. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetVMSecurityRulesAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, SecurityGroupViewParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetVMSecurityRulesWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - public static TroubleshootingResult BeginGetTroubleshooting(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters) - { - return operations.BeginGetTroubleshootingAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Initiate troubleshooting on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to troubleshoot. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetTroubleshootingAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, TroubleshootingParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetTroubleshootingWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Get the last completed troubleshooting result on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting result. - /// - public static TroubleshootingResult BeginGetTroubleshootingResult(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters) - { - return operations.BeginGetTroubleshootingResultAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Get the last completed troubleshooting result on a specified resource - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the resource to query the troubleshooting result. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetTroubleshootingResultAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, QueryTroubleshootingParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetTroubleshootingResultWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Configures flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - public static FlowLogInformation BeginSetFlowLogConfiguration(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogInformation parameters) - { - return operations.BeginSetFlowLogConfigurationAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Configures flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define the configuration of flow log. - /// - /// - /// The cancellation token. - /// - public static async Task BeginSetFlowLogConfigurationAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogInformation parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginSetFlowLogConfigurationWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - public static FlowLogInformation BeginGetFlowLogStatus(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters) - { - return operations.BeginGetFlowLogStatusAsync(resourceGroupName, networkWatcherName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Queries status of flow log on a specified resource. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the network watcher resource group. - /// - /// - /// The name of the network watcher resource. - /// - /// - /// Parameters that define a resource to query flow log status. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetFlowLogStatusAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, FlowLogStatusParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetFlowLogStatusWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/PacketCapturesOperations.cs b/Samples/test/end-to-end/network/Client/PacketCapturesOperations.cs index d31a0ad80..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/PacketCapturesOperations.cs +++ b/Samples/test/end-to-end/network/Client/PacketCapturesOperations.cs @@ -1,1368 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PacketCapturesOperations operations. - /// - internal partial class PacketCapturesOperations : IServiceOperations, IPacketCapturesOperations - { - /// - /// Initializes a new instance of the PacketCapturesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal PacketCapturesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets a packet capture session by name. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (packetCaptureName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "packetCaptureName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("packetCaptureName", packetCaptureName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{packetCaptureName}", System.Uri.EscapeDataString(packetCaptureName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Stops a specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task StopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Query the status of a running packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetStatusWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Lists all packet capture sessions within the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (packetCaptureName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "packetCaptureName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("packetCaptureName", packetCaptureName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{packetCaptureName}", System.Uri.EscapeDataString(packetCaptureName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (packetCaptureName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "packetCaptureName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("packetCaptureName", packetCaptureName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{packetCaptureName}", System.Uri.EscapeDataString(packetCaptureName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Stops a specified packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (packetCaptureName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "packetCaptureName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("packetCaptureName", packetCaptureName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginStop", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/stop").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{packetCaptureName}", System.Uri.EscapeDataString(packetCaptureName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Query the status of a running packet capture session. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetStatusWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string packetCaptureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkWatcherName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); - } - if (packetCaptureName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "packetCaptureName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkWatcherName", networkWatcherName); - tracingParameters.Add("packetCaptureName", packetCaptureName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetStatus", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/queryStatus").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); - _url = _url.Replace("{packetCaptureName}", System.Uri.EscapeDataString(packetCaptureName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/PacketCapturesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/PacketCapturesOperationsExtensions.cs index 1c42f2cb6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/PacketCapturesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/PacketCapturesOperationsExtensions.cs @@ -1,477 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PacketCapturesOperations. - /// - public static partial class PacketCapturesOperationsExtensions - { - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - public static PacketCaptureResult Create(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters) - { - return operations.CreateAsync(resourceGroupName, networkWatcherName, packetCaptureName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets a packet capture session by name. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - public static PacketCaptureResult Get(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName) - { - return operations.GetAsync(resourceGroupName, networkWatcherName, packetCaptureName).GetAwaiter().GetResult(); - } - - /// - /// Gets a packet capture session by name. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - public static void Delete(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName) - { - operations.DeleteAsync(resourceGroupName, networkWatcherName, packetCaptureName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Stops a specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - public static void Stop(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName) - { - operations.StopAsync(resourceGroupName, networkWatcherName, packetCaptureName).GetAwaiter().GetResult(); - } - - /// - /// Stops a specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The cancellation token. - /// - public static async Task StopAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.StopWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Query the status of a running packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - public static PacketCaptureQueryStatusResult GetStatus(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName) - { - return operations.GetStatusAsync(resourceGroupName, networkWatcherName, packetCaptureName).GetAwaiter().GetResult(); - } - - /// - /// Query the status of a running packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - /// - /// The cancellation token. - /// - public static async Task GetStatusAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetStatusWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists all packet capture sessions within the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - public static IEnumerable List(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName) - { - return operations.ListAsync(resourceGroupName, networkWatcherName).GetAwaiter().GetResult(); - } - - /// - /// Lists all packet capture sessions within the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkWatcherName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - public static PacketCaptureResult BeginCreate(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters) - { - return operations.BeginCreateAsync(resourceGroupName, networkWatcherName, packetCaptureName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Create and start a packet capture on the specified VM. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// Parameters that define the create packet capture operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapture parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - public static void BeginDelete(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName) - { - operations.BeginDeleteAsync(resourceGroupName, networkWatcherName, packetCaptureName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Stops a specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - public static void BeginStop(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName) - { - operations.BeginStopAsync(resourceGroupName, networkWatcherName, packetCaptureName).GetAwaiter().GetResult(); - } - - /// - /// Stops a specified packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network watcher. - /// - /// - /// The name of the packet capture session. - /// - /// - /// The cancellation token. - /// - public static async Task BeginStopAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Query the status of a running packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - public static PacketCaptureQueryStatusResult BeginGetStatus(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName) - { - return operations.BeginGetStatusAsync(resourceGroupName, networkWatcherName, packetCaptureName).GetAwaiter().GetResult(); - } - - /// - /// Query the status of a running packet capture session. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the Network Watcher resource. - /// - /// - /// The name given to the packet capture session. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetStatusAsync(this IPacketCapturesOperations operations, string resourceGroupName, string networkWatcherName, string packetCaptureName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetStatusWithHttpMessagesAsync(resourceGroupName, networkWatcherName, packetCaptureName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/PublicIPAddressesOperations.cs b/Samples/test/end-to-end/network/Client/PublicIPAddressesOperations.cs index 6406ee272..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/PublicIPAddressesOperations.cs +++ b/Samples/test/end-to-end/network/Client/PublicIPAddressesOperations.cs @@ -1,1415 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PublicIPAddressesOperations operations. - /// - internal partial class PublicIPAddressesOperations : IServiceOperations, IPublicIPAddressesOperations - { - /// - /// Initializes a new instance of the PublicIPAddressesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal PublicIPAddressesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, publicIpAddressName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified public IP address in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (publicIpAddressName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "publicIpAddressName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("publicIpAddressName", publicIpAddressName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{publicIpAddressName}", System.Uri.EscapeDataString(publicIpAddressName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, publicIpAddressName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/publicIPAddresses").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (publicIpAddressName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "publicIpAddressName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("publicIpAddressName", publicIpAddressName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{publicIpAddressName}", System.Uri.EscapeDataString(publicIpAddressName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 202 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (publicIpAddressName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "publicIpAddressName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("publicIpAddressName", publicIpAddressName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{publicIpAddressName}", System.Uri.EscapeDataString(publicIpAddressName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/PublicIPAddressesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/PublicIPAddressesOperationsExtensions.cs index 741b363c8..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/PublicIPAddressesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/PublicIPAddressesOperationsExtensions.cs @@ -1,363 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PublicIPAddressesOperations. - /// - public static partial class PublicIPAddressesOperationsExtensions - { - /// - /// Deletes the specified public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - public static void Delete(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName) - { - operations.DeleteAsync(resourceGroupName, publicIpAddressName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, publicIpAddressName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified public IP address in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - public static PublicIPAddress Get(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, publicIpAddressName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified public IP address in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, publicIpAddressName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address operation. - /// - public static PublicIPAddress CreateOrUpdate(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, publicIpAddressName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, publicIpAddressName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this IPublicIPAddressesOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this IPublicIPAddressesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this IPublicIPAddressesOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IPublicIPAddressesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - public static void BeginDelete(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName) - { - operations.BeginDeleteAsync(resourceGroupName, publicIpAddressName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the subnet. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, publicIpAddressName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address operation. - /// - public static PublicIPAddress BeginCreateOrUpdate(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, publicIpAddressName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a static or dynamic public IP address. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the public IP address. - /// - /// - /// Parameters supplied to the create or update public IP address operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IPublicIPAddressesOperations operations, string resourceGroupName, string publicIpAddressName, PublicIPAddress parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, publicIpAddressName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this IPublicIPAddressesOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all the public IP addresses in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this IPublicIPAddressesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IPublicIPAddressesOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all public IP addresses in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IPublicIPAddressesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RouteFilterRulesOperations.cs b/Samples/test/end-to-end/network/Client/RouteFilterRulesOperations.cs index 13d97d4e2..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RouteFilterRulesOperations.cs +++ b/Samples/test/end-to-end/network/Client/RouteFilterRulesOperations.cs @@ -1,1357 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RouteFilterRulesOperations operations. - /// - internal partial class RouteFilterRulesOperations : IServiceOperations, IRouteFilterRulesOperations - { - /// - /// Initializes a new instance of the RouteFilterRulesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal RouteFilterRulesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified rule from a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (ruleName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("ruleName", ruleName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByRouteFilterWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByRouteFilter", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (ruleName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("ruleName", ruleName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (ruleName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); - } - if (routeFilterRuleParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterRuleParameters"); - } - if (routeFilterRuleParameters != null) - { - routeFilterRuleParameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - if (routeFilterRuleParameters == null) - { - routeFilterRuleParameters = new RouteFilterRule(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("ruleName", ruleName); - tracingParameters.Add("routeFilterRuleParameters", routeFilterRuleParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(routeFilterRuleParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(routeFilterRuleParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates a route in the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (ruleName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); - } - if (routeFilterRuleParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterRuleParameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - if (routeFilterRuleParameters == null) - { - routeFilterRuleParameters = new PatchRouteFilterRule(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("ruleName", ruleName); - tracingParameters.Add("routeFilterRuleParameters", routeFilterRuleParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(routeFilterRuleParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(routeFilterRuleParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByRouteFilterNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByRouteFilterNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RouteFilterRulesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/RouteFilterRulesOperationsExtensions.cs index 2af5bde2a..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RouteFilterRulesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/RouteFilterRulesOperationsExtensions.cs @@ -1,435 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for RouteFilterRulesOperations. - /// - public static partial class RouteFilterRulesOperationsExtensions - { - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - public static void Delete(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName) - { - operations.DeleteAsync(resourceGroupName, routeFilterName, ruleName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified rule from a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - public static RouteFilterRule Get(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName) - { - return operations.GetAsync(resourceGroupName, routeFilterName, ruleName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified rule from a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule operation. - /// - public static RouteFilterRule CreateOrUpdate(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - public static RouteFilterRule Update(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters) - { - return operations.UpdateAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters).GetAwaiter().GetResult(); - } - - /// - /// Updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - public static IPage ListByRouteFilter(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName) - { - return operations.ListByRouteFilterAsync(resourceGroupName, routeFilterName).GetAwaiter().GetResult(); - } - - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByRouteFilterAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByRouteFilterWithHttpMessagesAsync(resourceGroupName, routeFilterName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - public static void BeginDelete(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName) - { - operations.BeginDeleteAsync(resourceGroupName, routeFilterName, ruleName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified rule from a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the rule. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule operation. - /// - public static RouteFilterRule BeginCreateOrUpdate(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the create or update route filter rule operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, RouteFilterRule routeFilterRuleParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - public static RouteFilterRule BeginUpdate(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters) - { - return operations.BeginUpdateAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters).GetAwaiter().GetResult(); - } - - /// - /// Updates a route in the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The name of the route filter rule. - /// - /// - /// Parameters supplied to the update route filter rule operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginUpdateAsync(this IRouteFilterRulesOperations operations, string resourceGroupName, string routeFilterName, string ruleName, PatchRouteFilterRule routeFilterRuleParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListByRouteFilterNext(this IRouteFilterRulesOperations operations, string nextPageLink) - { - return operations.ListByRouteFilterNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all RouteFilterRules in a route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByRouteFilterNextAsync(this IRouteFilterRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByRouteFilterNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RouteFiltersOperations.cs b/Samples/test/end-to-end/network/Client/RouteFiltersOperations.cs index 633d03bf0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RouteFiltersOperations.cs +++ b/Samples/test/end-to-end/network/Client/RouteFiltersOperations.cs @@ -1,1650 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RouteFiltersOperations operations. - /// - internal partial class RouteFiltersOperations : IServiceOperations, IRouteFiltersOperations - { - /// - /// Initializes a new instance of the RouteFiltersOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal RouteFiltersOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeFilterName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Expands referenced express route bgp peering resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, routeFilterParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, routeFilterParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all route filters in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route filters in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/routeFilters").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified route filter. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (routeFilterParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterParameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("routeFilterParameters", routeFilterParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(routeFilterParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(routeFilterParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeFilterName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterName"); - } - if (routeFilterParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeFilterParameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeFilterName", routeFilterName); - tracingParameters.Add("routeFilterParameters", routeFilterParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeFilterName}", System.Uri.EscapeDataString(routeFilterName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(routeFilterParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(routeFilterParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route filters in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route filters in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RouteFiltersOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/RouteFiltersOperationsExtensions.cs index f26880fc3..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RouteFiltersOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/RouteFiltersOperationsExtensions.cs @@ -1,455 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for RouteFiltersOperations. - /// - public static partial class RouteFiltersOperationsExtensions - { - /// - /// Deletes the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - public static void Delete(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName) - { - operations.DeleteAsync(resourceGroupName, routeFilterName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, routeFilterName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Expands referenced express route bgp peering resources. - /// - public static RouteFilter Get(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, routeFilterName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Expands referenced express route bgp peering resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, routeFilterName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - public static RouteFilter CreateOrUpdate(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, routeFilterName, routeFilterParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, routeFilterParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - public static RouteFilter Update(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters) - { - return operations.UpdateAsync(resourceGroupName, routeFilterName, routeFilterParameters).GetAwaiter().GetResult(); - } - - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, routeFilterParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route filters in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage ListByResourceGroup(this IRouteFiltersOperations operations, string resourceGroupName) - { - return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all route filters in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByResourceGroupAsync(this IRouteFiltersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route filters in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage List(this IRouteFiltersOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all route filters in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IRouteFiltersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - public static void BeginDelete(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName) - { - operations.BeginDeleteAsync(resourceGroupName, routeFilterName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified route filter. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeFilterName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - public static RouteFilter BeginCreateOrUpdate(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, routeFilterName, routeFilterParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the create or update route filter operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, routeFilterParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - public static RouteFilter BeginUpdate(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters) - { - return operations.BeginUpdateAsync(resourceGroupName, routeFilterName, routeFilterParameters).GetAwaiter().GetResult(); - } - - /// - /// Updates a route filter in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route filter. - /// - /// - /// Parameters supplied to the update route filter operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginUpdateAsync(this IRouteFiltersOperations operations, string resourceGroupName, string routeFilterName, PatchRouteFilter routeFilterParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, routeFilterName, routeFilterParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route filters in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListByResourceGroupNext(this IRouteFiltersOperations operations, string nextPageLink) - { - return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all route filters in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListByResourceGroupNextAsync(this IRouteFiltersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route filters in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IRouteFiltersOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all route filters in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IRouteFiltersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RouteTablesOperations.cs b/Samples/test/end-to-end/network/Client/RouteTablesOperations.cs index 19ac1ed45..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RouteTablesOperations.cs +++ b/Samples/test/end-to-end/network/Client/RouteTablesOperations.cs @@ -1,1415 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RouteTablesOperations operations. - /// - internal partial class RouteTablesOperations : IServiceOperations, IRouteTablesOperations - { - /// - /// Initializes a new instance of the RouteTablesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal RouteTablesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeTableName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeTableName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeTableName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeTableName", routeTableName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeTableName}", System.Uri.EscapeDataString(routeTableName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, RouteTable parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeTableName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all route tables in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route tables in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/routeTables").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeTableName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeTableName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeTableName", routeTableName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeTableName}", System.Uri.EscapeDataString(routeTableName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, RouteTable parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeTableName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeTableName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeTableName", routeTableName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeTableName}", System.Uri.EscapeDataString(routeTableName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route tables in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all route tables in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RouteTablesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/RouteTablesOperationsExtensions.cs index c1031db0c..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RouteTablesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/RouteTablesOperationsExtensions.cs @@ -1,363 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for RouteTablesOperations. - /// - public static partial class RouteTablesOperationsExtensions - { - /// - /// Deletes the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - public static void Delete(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName) - { - operations.DeleteAsync(resourceGroupName, routeTableName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, routeTableName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Expands referenced resources. - /// - public static RouteTable Get(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, routeTableName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, routeTableName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - public static RouteTable CreateOrUpdate(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, RouteTable parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, routeTableName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, RouteTable parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeTableName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route tables in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this IRouteTablesOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all route tables in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IRouteTablesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route tables in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this IRouteTablesOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all route tables in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this IRouteTablesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - public static void BeginDelete(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName) - { - operations.BeginDeleteAsync(resourceGroupName, routeTableName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeTableName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - public static RouteTable BeginCreateOrUpdate(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, RouteTable parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, routeTableName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Create or updates a route table in a specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Parameters supplied to the create or update route table operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IRouteTablesOperations operations, string resourceGroupName, string routeTableName, RouteTable parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeTableName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route tables in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IRouteTablesOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all route tables in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IRouteTablesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all route tables in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this IRouteTablesOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all route tables in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this IRouteTablesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RoutesOperations.cs b/Samples/test/end-to-end/network/Client/RoutesOperations.cs index eeab2358e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RoutesOperations.cs +++ b/Samples/test/end-to-end/network/Client/RoutesOperations.cs @@ -1,1102 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// RoutesOperations operations. - /// - internal partial class RoutesOperations : IServiceOperations, IRoutesOperations - { - /// - /// Initializes a new instance of the RoutesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal RoutesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified route from a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeTableName, routeName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified route from a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeTableName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeTableName"); - } - if (routeName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeTableName", routeTableName); - tracingParameters.Add("routeName", routeName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeTableName}", System.Uri.EscapeDataString(routeTableName)); - _url = _url.Replace("{routeName}", System.Uri.EscapeDataString(routeName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Route routeParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeTableName, routeName, routeParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all routes in a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string routeTableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeTableName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeTableName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeTableName", routeTableName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeTableName}", System.Uri.EscapeDataString(routeTableName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified route from a route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeTableName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeTableName"); - } - if (routeName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeTableName", routeTableName); - tracingParameters.Add("routeName", routeName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeTableName}", System.Uri.EscapeDataString(routeTableName)); - _url = _url.Replace("{routeName}", System.Uri.EscapeDataString(routeName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 200 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string routeTableName, string routeName, Route routeParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (routeTableName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeTableName"); - } - if (routeName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeName"); - } - if (routeParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "routeParameters"); - } - if (routeParameters != null) - { - routeParameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("routeTableName", routeTableName); - tracingParameters.Add("routeName", routeName); - tracingParameters.Add("routeParameters", routeParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{routeTableName}", System.Uri.EscapeDataString(routeTableName)); - _url = _url.Replace("{routeName}", System.Uri.EscapeDataString(routeName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(routeParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(routeParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all routes in a route table. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/RoutesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/RoutesOperationsExtensions.cs index e49638df6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/RoutesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/RoutesOperationsExtensions.cs @@ -1,331 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for RoutesOperations. - /// - public static partial class RoutesOperationsExtensions - { - /// - /// Deletes the specified route from a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - public static void Delete(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName) - { - operations.DeleteAsync(resourceGroupName, routeTableName, routeName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified route from a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, routeTableName, routeName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified route from a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - public static Route Get(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName) - { - return operations.GetAsync(resourceGroupName, routeTableName, routeName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified route from a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, routeTableName, routeName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - public static Route CreateOrUpdate(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName, Route routeParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, routeTableName, routeName, routeParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName, Route routeParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeTableName, routeName, routeParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all routes in a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - public static IPage List(this IRoutesOperations operations, string resourceGroupName, string routeTableName) - { - return operations.ListAsync(resourceGroupName, routeTableName).GetAwaiter().GetResult(); - } - - /// - /// Gets all routes in a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IRoutesOperations operations, string resourceGroupName, string routeTableName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, routeTableName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified route from a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - public static void BeginDelete(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName) - { - operations.BeginDeleteAsync(resourceGroupName, routeTableName, routeName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified route from a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, routeTableName, routeName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - public static Route BeginCreateOrUpdate(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName, Route routeParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, routeTableName, routeName, routeParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a route in the specified route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the route table. - /// - /// - /// The name of the route. - /// - /// - /// Parameters supplied to the create or update route operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IRoutesOperations operations, string resourceGroupName, string routeTableName, string routeName, Route routeParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, routeTableName, routeName, routeParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all routes in a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IRoutesOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all routes in a route table. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IRoutesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/SecurityRulesOperations.cs b/Samples/test/end-to-end/network/Client/SecurityRulesOperations.cs index eb6183d20..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/SecurityRulesOperations.cs +++ b/Samples/test/end-to-end/network/Client/SecurityRulesOperations.cs @@ -1,1104 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SecurityRulesOperations operations. - /// - internal partial class SecurityRulesOperations : IServiceOperations, ISecurityRulesOperations - { - /// - /// Initializes a new instance of the SecurityRulesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal SecurityRulesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified network security rule. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get the specified network security rule. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkSecurityGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkSecurityGroupName"); - } - if (securityRuleName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "securityRuleName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkSecurityGroupName", networkSecurityGroupName); - tracingParameters.Add("securityRuleName", securityRuleName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkSecurityGroupName}", System.Uri.EscapeDataString(networkSecurityGroupName)); - _url = _url.Replace("{securityRuleName}", System.Uri.EscapeDataString(securityRuleName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a security rule in the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all security rules in a network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkSecurityGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkSecurityGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkSecurityGroupName", networkSecurityGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkSecurityGroupName}", System.Uri.EscapeDataString(networkSecurityGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified network security rule. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkSecurityGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkSecurityGroupName"); - } - if (securityRuleName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "securityRuleName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkSecurityGroupName", networkSecurityGroupName); - tracingParameters.Add("securityRuleName", securityRuleName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkSecurityGroupName}", System.Uri.EscapeDataString(networkSecurityGroupName)); - _url = _url.Replace("{securityRuleName}", System.Uri.EscapeDataString(securityRuleName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 202 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a security rule in the specified network security group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (networkSecurityGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "networkSecurityGroupName"); - } - if (securityRuleName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "securityRuleName"); - } - if (securityRuleParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "securityRuleParameters"); - } - if (securityRuleParameters != null) - { - securityRuleParameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("networkSecurityGroupName", networkSecurityGroupName); - tracingParameters.Add("securityRuleName", securityRuleName); - tracingParameters.Add("securityRuleParameters", securityRuleParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{networkSecurityGroupName}", System.Uri.EscapeDataString(networkSecurityGroupName)); - _url = _url.Replace("{securityRuleName}", System.Uri.EscapeDataString(securityRuleName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(securityRuleParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(securityRuleParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all security rules in a network security group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/SecurityRulesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/SecurityRulesOperationsExtensions.cs index e77adbdd0..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/SecurityRulesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/SecurityRulesOperationsExtensions.cs @@ -1,335 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SecurityRulesOperations. - /// - public static partial class SecurityRulesOperationsExtensions - { - /// - /// Deletes the specified network security rule. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - public static void Delete(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName) - { - operations.DeleteAsync(resourceGroupName, networkSecurityGroupName, securityRuleName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network security rule. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Get the specified network security rule. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - public static SecurityRule Get(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName) - { - return operations.GetAsync(resourceGroupName, networkSecurityGroupName, securityRuleName).GetAwaiter().GetResult(); - } - - /// - /// Get the specified network security rule. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a security rule in the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - public static SecurityRule CreateOrUpdate(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a security rule in the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all security rules in a network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - public static IPage List(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName) - { - return operations.ListAsync(resourceGroupName, networkSecurityGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all security rules in a network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified network security rule. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - public static void BeginDelete(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName) - { - operations.BeginDeleteAsync(resourceGroupName, networkSecurityGroupName, securityRuleName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified network security rule. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a security rule in the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - public static SecurityRule BeginCreateOrUpdate(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a security rule in the specified network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the network security group. - /// - /// - /// The name of the security rule. - /// - /// - /// Parameters supplied to the create or update network security rule - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this ISecurityRulesOperations operations, string resourceGroupName, string networkSecurityGroupName, string securityRuleName, SecurityRule securityRuleParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all security rules in a network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ISecurityRulesOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all security rules in a network security group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this ISecurityRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/SubnetsOperations.cs b/Samples/test/end-to-end/network/Client/SubnetsOperations.cs index c45db1905..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/SubnetsOperations.cs +++ b/Samples/test/end-to-end/network/Client/SubnetsOperations.cs @@ -1,1106 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SubnetsOperations operations. - /// - internal partial class SubnetsOperations : IServiceOperations, ISubnetsOperations - { - /// - /// Initializes a new instance of the SubnetsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal SubnetsOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified subnet. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, subnetName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified subnet by virtual network and resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (subnetName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subnetName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("subnetName", subnetName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subnetName}", System.Uri.EscapeDataString(subnetName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified subnet. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (subnetName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subnetName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("subnetName", subnetName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subnetName}", System.Uri.EscapeDataString(subnetName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (subnetName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subnetName"); - } - if (subnetParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subnetParameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("subnetName", subnetName); - tracingParameters.Add("subnetParameters", subnetParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subnetName}", System.Uri.EscapeDataString(subnetName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(subnetParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(subnetParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/SubnetsOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/SubnetsOperationsExtensions.cs index 83b5eb8f6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/SubnetsOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/SubnetsOperationsExtensions.cs @@ -1,337 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SubnetsOperations. - /// - public static partial class SubnetsOperationsExtensions - { - /// - /// Deletes the specified subnet. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - public static void Delete(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName) - { - operations.DeleteAsync(resourceGroupName, virtualNetworkName, subnetName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified subnet. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, subnetName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified subnet by virtual network and resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - public static Subnet Get(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, virtualNetworkName, subnetName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified subnet by virtual network and resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, subnetName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - public static Subnet CreateOrUpdate(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - public static IPage List(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName) - { - return operations.ListAsync(resourceGroupName, virtualNetworkName).GetAwaiter().GetResult(); - } - - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified subnet. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - public static void BeginDelete(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName) - { - operations.BeginDeleteAsync(resourceGroupName, virtualNetworkName, subnetName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified subnet. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, subnetName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - public static Subnet BeginCreateOrUpdate(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a subnet in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the subnet. - /// - /// - /// Parameters supplied to the create or update subnet operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this ISubnetsOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ISubnetsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all subnets in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this ISubnetsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/UsagesOperations.cs b/Samples/test/end-to-end/network/Client/UsagesOperations.cs index b39809fd6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/UsagesOperations.cs +++ b/Samples/test/end-to-end/network/Client/UsagesOperations.cs @@ -1,417 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// UsagesOperations operations. - /// - internal partial class UsagesOperations : IServiceOperations, IUsagesOperations - { - /// - /// Initializes a new instance of the UsagesOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal UsagesOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Lists compute usages for a subscription. - /// - /// - /// The location where resource usage is queried. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "location"); - } - if (location != null) - { - if (!System.Text.RegularExpressions.Regex.IsMatch(location, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "location", "^[-\\w\\._]+$"); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("location", location); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/usages").ToString(); - _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Lists compute usages for a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/UsagesOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/UsagesOperationsExtensions.cs index 14b643e4e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/UsagesOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/UsagesOperationsExtensions.cs @@ -1,89 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for UsagesOperations. - /// - public static partial class UsagesOperationsExtensions - { - /// - /// Lists compute usages for a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The location where resource usage is queried. - /// - public static IPage List(this IUsagesOperations operations, string location) - { - return operations.ListAsync(location).GetAwaiter().GetResult(); - } - - /// - /// Lists compute usages for a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The location where resource usage is queried. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IUsagesOperations operations, string location, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(location, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Lists compute usages for a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IUsagesOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Lists compute usages for a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IUsagesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperations.cs b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperations.cs index 0ff5b3e96..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperations.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperations.cs @@ -1,1776 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworkGatewayConnectionsOperations operations. - /// - internal partial class VirtualNetworkGatewayConnectionsOperations : IServiceOperations, IVirtualNetworkGatewayConnectionsOperations - { - /// - /// Initializes a new instance of the VirtualNetworkGatewayConnectionsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal VirtualNetworkGatewayConnectionsOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Creates or updates a virtual network gateway connection in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified virtual network gateway connection by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayConnectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayConnectionName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayConnectionName", virtualNetworkGatewayConnectionName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayConnectionName}", System.Uri.EscapeDataString(virtualNetworkGatewayConnectionName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual - /// network gateway connection shared key for passed virtual network gateway - /// connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway connection - /// Shared key operation throughNetwork resource provider. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> SetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginSetSharedKeyWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves - /// information about the specified virtual network gateway connection shared - /// key through Network resource provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection shared key name. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayConnectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayConnectionName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayConnectionName", virtualNetworkGatewayConnectionName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetSharedKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayConnectionName}", System.Uri.EscapeDataString(virtualNetworkGatewayConnectionName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all the - /// virtual network gateways connections created. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets the - /// virtual network gateway connection shared key for passed virtual network - /// gateway connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway connection - /// shared key operation through network resource provider. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> ResetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginResetSharedKeyWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Creates or updates a virtual network gateway connection in the specified - /// resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayConnectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayConnectionName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayConnectionName", virtualNetworkGatewayConnectionName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayConnectionName}", System.Uri.EscapeDataString(virtualNetworkGatewayConnectionName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayConnectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayConnectionName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayConnectionName", virtualNetworkGatewayConnectionName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayConnectionName}", System.Uri.EscapeDataString(virtualNetworkGatewayConnectionName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual - /// network gateway connection shared key for passed virtual network gateway - /// connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway connection - /// Shared key operation throughNetwork resource provider. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginSetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayConnectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayConnectionName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayConnectionName", virtualNetworkGatewayConnectionName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginSetSharedKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayConnectionName}", System.Uri.EscapeDataString(virtualNetworkGatewayConnectionName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 201 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets the - /// virtual network gateway connection shared key for passed virtual network - /// gateway connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway connection - /// shared key operation through network resource provider. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginResetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayConnectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayConnectionName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayConnectionName", virtualNetworkGatewayConnectionName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginResetSharedKey", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey/reset").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayConnectionName}", System.Uri.EscapeDataString(virtualNetworkGatewayConnectionName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all the - /// virtual network gateways connections created. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperationsExtensions.cs index 965548b96..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewayConnectionsOperationsExtensions.cs @@ -1,567 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for VirtualNetworkGatewayConnectionsOperations. - /// - public static partial class VirtualNetworkGatewayConnectionsOperationsExtensions - { - /// - /// Creates or updates a virtual network gateway connection in the specified - /// resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - public static VirtualNetworkGatewayConnection CreateOrUpdate(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a virtual network gateway connection in the specified - /// resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the specified virtual network gateway connection by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - public static VirtualNetworkGatewayConnection Get(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName) - { - return operations.GetAsync(resourceGroupName, virtualNetworkGatewayConnectionName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified virtual network gateway connection by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - public static void Delete(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName) - { - operations.DeleteAsync(resourceGroupName, virtualNetworkGatewayConnectionName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual - /// network gateway connection shared key for passed virtual network gateway - /// connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway connection - /// Shared key operation throughNetwork resource provider. - /// - public static ConnectionSharedKey SetSharedKey(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters) - { - return operations.SetSharedKeyAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).GetAwaiter().GetResult(); - } - - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual - /// network gateway connection shared key for passed virtual network gateway - /// connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway connection - /// Shared key operation throughNetwork resource provider. - /// - /// - /// The cancellation token. - /// - public static async Task SetSharedKeyAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.SetSharedKeyWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves - /// information about the specified virtual network gateway connection shared - /// key through Network resource provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection shared key name. - /// - public static ConnectionSharedKey GetSharedKey(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName) - { - return operations.GetSharedKeyAsync(resourceGroupName, virtualNetworkGatewayConnectionName).GetAwaiter().GetResult(); - } - - /// - /// The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves - /// information about the specified virtual network gateway connection shared - /// key through Network resource provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection shared key name. - /// - /// - /// The cancellation token. - /// - public static async Task GetSharedKeyAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetSharedKeyWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all the - /// virtual network gateways connections created. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all the - /// virtual network gateways connections created. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets the - /// virtual network gateway connection shared key for passed virtual network - /// gateway connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway connection - /// shared key operation through network resource provider. - /// - public static ConnectionResetSharedKey ResetSharedKey(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters) - { - return operations.ResetSharedKeyAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).GetAwaiter().GetResult(); - } - - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets the - /// virtual network gateway connection shared key for passed virtual network - /// gateway connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway connection - /// shared key operation through network resource provider. - /// - /// - /// The cancellation token. - /// - public static async Task ResetSharedKeyAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ResetSharedKeyWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a virtual network gateway connection in the specified - /// resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - public static VirtualNetworkGatewayConnection BeginCreateOrUpdate(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a virtual network gateway connection in the specified - /// resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// Parameters supplied to the create or update virtual network gateway - /// connection operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - public static void BeginDelete(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName) - { - operations.BeginDeleteAsync(resourceGroupName, virtualNetworkGatewayConnectionName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network Gateway connection. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway connection. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual - /// network gateway connection shared key for passed virtual network gateway - /// connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway connection - /// Shared key operation throughNetwork resource provider. - /// - public static ConnectionSharedKey BeginSetSharedKey(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters) - { - return operations.BeginSetSharedKeyAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).GetAwaiter().GetResult(); - } - - /// - /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual - /// network gateway connection shared key for passed virtual network gateway - /// connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection name. - /// - /// - /// Parameters supplied to the Begin Set Virtual Network Gateway connection - /// Shared key operation throughNetwork resource provider. - /// - /// - /// The cancellation token. - /// - public static async Task BeginSetSharedKeyAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginSetSharedKeyWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets the - /// virtual network gateway connection shared key for passed virtual network - /// gateway connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway connection - /// shared key operation through network resource provider. - /// - public static ConnectionResetSharedKey BeginResetSharedKey(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters) - { - return operations.BeginResetSharedKeyAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).GetAwaiter().GetResult(); - } - - /// - /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets the - /// virtual network gateway connection shared key for passed virtual network - /// gateway connection in the specified resource group through Network resource - /// provider. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The virtual network gateway connection reset shared key Name. - /// - /// - /// Parameters supplied to the begin reset virtual network gateway connection - /// shared key operation through network resource provider. - /// - /// - /// The cancellation token. - /// - public static async Task BeginResetSharedKeyAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginResetSharedKeyWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all the - /// virtual network gateways connections created. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IVirtualNetworkGatewayConnectionsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// The List VirtualNetworkGatewayConnections operation retrieves all the - /// virtual network gateways connections created. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IVirtualNetworkGatewayConnectionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperations.cs b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperations.cs index 301a304c6..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperations.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperations.cs @@ -1,2191 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworkGatewaysOperations operations. - /// - internal partial class VirtualNetworkGatewaysOperations : IServiceOperations, IVirtualNetworkGatewaysOperations - { - /// - /// Initializes a new instance of the VirtualNetworkGatewaysOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal VirtualNetworkGatewaysOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Creates or updates a virtual network gateway in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified virtual network gateway by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Resets the primary of the virtual network gateway in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of the - /// active-active feature enabled gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> ResetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginResetWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, gatewayVip, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Generates VPN client package for P2S client of the virtual network gateway - /// in the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to the generate virtual network gateway VPN client - /// package operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GeneratevpnclientpackageWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, VpnClientParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Generatevpnclientpackage", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 202) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetBgpPeerStatusWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetBgpPeerStatusWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, peer, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// This operation retrieves a list of routes the virtual network gateway has - /// learned, including routes learned from BGP peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetLearnedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetLearnedRoutesWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// This operation retrieves a list of routes the virtual network gateway is - /// advertising to the specified peer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> GetAdvertisedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginGetAdvertisedRoutesWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, peer, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Creates or updates a virtual network gateway in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 202 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Resets the primary of the virtual network gateway in the specified resource - /// group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of the - /// active-active feature enabled gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginResetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("gatewayVip", gatewayVip); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginReset", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (gatewayVip != null) - { - _queryParameters.Add(string.Format("gatewayVip={0}", System.Uri.EscapeDataString(gatewayVip))); - } - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetBgpPeerStatusWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("peer", peer); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetBgpPeerStatus", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (peer != null) - { - _queryParameters.Add(string.Format("peer={0}", System.Uri.EscapeDataString(peer))); - } - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// This operation retrieves a list of routes the virtual network gateway has - /// learned, including routes learned from BGP peers. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetLearnedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetLearnedRoutes", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// This operation retrieves a list of routes the virtual network gateway is - /// advertising to the specified peer. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginGetAdvertisedRoutesWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName, string peer, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkGatewayName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName"); - } - if (peer == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "peer"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkGatewayName", virtualNetworkGatewayName); - tracingParameters.Add("peer", peer); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginGetAdvertisedRoutes", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkGatewayName}", System.Uri.EscapeDataString(virtualNetworkGatewayName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (peer != null) - { - _queryParameters.Add(string.Format("peer={0}", System.Uri.EscapeDataString(peer))); - } - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperationsExtensions.cs index e85e380aa..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworkGatewaysOperationsExtensions.cs @@ -1,721 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for VirtualNetworkGatewaysOperations. - /// - public static partial class VirtualNetworkGatewaysOperationsExtensions - { - /// - /// Creates or updates a virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway operation. - /// - public static VirtualNetworkGateway CreateOrUpdate(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, virtualNetworkGatewayName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the specified virtual network gateway by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - public static VirtualNetworkGateway Get(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName) - { - return operations.GetAsync(resourceGroupName, virtualNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified virtual network gateway by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - public static void Delete(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName) - { - operations.DeleteAsync(resourceGroupName, virtualNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Resets the primary of the virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of the - /// active-active feature enabled gateway. - /// - public static VirtualNetworkGateway Reset(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string)) - { - return operations.ResetAsync(resourceGroupName, virtualNetworkGatewayName, gatewayVip).GetAwaiter().GetResult(); - } - - /// - /// Resets the primary of the virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of the - /// active-active feature enabled gateway. - /// - /// - /// The cancellation token. - /// - public static async Task ResetAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ResetWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, gatewayVip, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Generates VPN client package for P2S client of the virtual network gateway - /// in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to the generate virtual network gateway VPN client - /// package operation. - /// - public static string Generatevpnclientpackage(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, VpnClientParameters parameters) - { - return operations.GeneratevpnclientpackageAsync(resourceGroupName, virtualNetworkGatewayName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Generates VPN client package for P2S client of the virtual network gateway - /// in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to the generate virtual network gateway VPN client - /// package operation. - /// - /// - /// The cancellation token. - /// - public static async Task GeneratevpnclientpackageAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, VpnClientParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GeneratevpnclientpackageWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - public static BgpPeerStatusListResult GetBgpPeerStatus(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string)) - { - return operations.GetBgpPeerStatusAsync(resourceGroupName, virtualNetworkGatewayName, peer).GetAwaiter().GetResult(); - } - - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - /// - /// The cancellation token. - /// - public static async Task GetBgpPeerStatusAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetBgpPeerStatusWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, peer, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// This operation retrieves a list of routes the virtual network gateway has - /// learned, including routes learned from BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - public static GatewayRouteListResult GetLearnedRoutes(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName) - { - return operations.GetLearnedRoutesAsync(resourceGroupName, virtualNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// This operation retrieves a list of routes the virtual network gateway has - /// learned, including routes learned from BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task GetLearnedRoutesAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetLearnedRoutesWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// This operation retrieves a list of routes the virtual network gateway is - /// advertising to the specified peer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - public static GatewayRouteListResult GetAdvertisedRoutes(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer) - { - return operations.GetAdvertisedRoutesAsync(resourceGroupName, virtualNetworkGatewayName, peer).GetAwaiter().GetResult(); - } - - /// - /// This operation retrieves a list of routes the virtual network gateway is - /// advertising to the specified peer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - /// - /// The cancellation token. - /// - public static async Task GetAdvertisedRoutesAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetAdvertisedRoutesWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, peer, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway operation. - /// - public static VirtualNetworkGateway BeginCreateOrUpdate(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, virtualNetworkGatewayName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Parameters supplied to create or update virtual network gateway operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, VirtualNetworkGateway parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - public static void BeginDelete(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName) - { - operations.BeginDeleteAsync(resourceGroupName, virtualNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network gateway. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Resets the primary of the virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of the - /// active-active feature enabled gateway. - /// - public static VirtualNetworkGateway BeginReset(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string)) - { - return operations.BeginResetAsync(resourceGroupName, virtualNetworkGatewayName, gatewayVip).GetAwaiter().GetResult(); - } - - /// - /// Resets the primary of the virtual network gateway in the specified resource - /// group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// Virtual network gateway vip address supplied to the begin reset of the - /// active-active feature enabled gateway. - /// - /// - /// The cancellation token. - /// - public static async Task BeginResetAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string gatewayVip = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginResetWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, gatewayVip, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - public static BgpPeerStatusListResult BeginGetBgpPeerStatus(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string)) - { - return operations.BeginGetBgpPeerStatusAsync(resourceGroupName, virtualNetworkGatewayName, peer).GetAwaiter().GetResult(); - } - - /// - /// The GetBgpPeerStatus operation retrieves the status of all BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer to retrieve the status of. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetBgpPeerStatusAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetBgpPeerStatusWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, peer, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// This operation retrieves a list of routes the virtual network gateway has - /// learned, including routes learned from BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - public static GatewayRouteListResult BeginGetLearnedRoutes(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName) - { - return operations.BeginGetLearnedRoutesAsync(resourceGroupName, virtualNetworkGatewayName).GetAwaiter().GetResult(); - } - - /// - /// This operation retrieves a list of routes the virtual network gateway has - /// learned, including routes learned from BGP peers. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetLearnedRoutesAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetLearnedRoutesWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// This operation retrieves a list of routes the virtual network gateway is - /// advertising to the specified peer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - public static GatewayRouteListResult BeginGetAdvertisedRoutes(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer) - { - return operations.BeginGetAdvertisedRoutesAsync(resourceGroupName, virtualNetworkGatewayName, peer).GetAwaiter().GetResult(); - } - - /// - /// This operation retrieves a list of routes the virtual network gateway is - /// advertising to the specified peer. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network gateway. - /// - /// - /// The IP address of the peer - /// - /// - /// The cancellation token. - /// - public static async Task BeginGetAdvertisedRoutesAsync(this IVirtualNetworkGatewaysOperations operations, string resourceGroupName, string virtualNetworkGatewayName, string peer, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginGetAdvertisedRoutesWithHttpMessagesAsync(resourceGroupName, virtualNetworkGatewayName, peer, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IVirtualNetworkGatewaysOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual network gateways by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IVirtualNetworkGatewaysOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperations.cs b/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperations.cs index b3435819e..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperations.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperations.cs @@ -1,1100 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworkPeeringsOperations operations. - /// - internal partial class VirtualNetworkPeeringsOperations : IServiceOperations, IVirtualNetworkPeeringsOperations - { - /// - /// Initializes a new instance of the VirtualNetworkPeeringsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal VirtualNetworkPeeringsOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified virtual network peering. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (virtualNetworkPeeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkPeeringName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("virtualNetworkPeeringName", virtualNetworkPeeringName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/virtualNetworkPeerings/{virtualNetworkPeeringName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{virtualNetworkPeeringName}", System.Uri.EscapeDataString(virtualNetworkPeeringName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/virtualNetworkPeerings").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (virtualNetworkPeeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkPeeringName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("virtualNetworkPeeringName", virtualNetworkPeeringName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/virtualNetworkPeerings/{virtualNetworkPeeringName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{virtualNetworkPeeringName}", System.Uri.EscapeDataString(virtualNetworkPeeringName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 204 && (int)_statusCode != 202) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (virtualNetworkPeeringName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkPeeringName"); - } - if (virtualNetworkPeeringParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkPeeringParameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("virtualNetworkPeeringName", virtualNetworkPeeringName); - tracingParameters.Add("virtualNetworkPeeringParameters", virtualNetworkPeeringParameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/virtualNetworkPeerings/{virtualNetworkPeeringName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{virtualNetworkPeeringName}", System.Uri.EscapeDataString(virtualNetworkPeeringName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(virtualNetworkPeeringParameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(virtualNetworkPeeringParameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperationsExtensions.cs index 6a7424456..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworkPeeringsOperationsExtensions.cs @@ -1,335 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for VirtualNetworkPeeringsOperations. - /// - public static partial class VirtualNetworkPeeringsOperationsExtensions - { - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - public static void Delete(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName) - { - operations.DeleteAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified virtual network peering. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - public static VirtualNetworkPeering Get(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName) - { - return operations.GetAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified virtual network peering. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - public static VirtualNetworkPeering CreateOrUpdate(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - public static IPage List(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName) - { - return operations.ListAsync(resourceGroupName, virtualNetworkName).GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - public static void BeginDelete(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName) - { - operations.BeginDeleteAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network peering. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the virtual network peering. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - public static VirtualNetworkPeering BeginCreateOrUpdate(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a peering in the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The name of the peering. - /// - /// - /// Parameters supplied to the create or update virtual network peering - /// operation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IVirtualNetworkPeeringsOperations operations, string resourceGroupName, string virtualNetworkName, string virtualNetworkPeeringName, VirtualNetworkPeering virtualNetworkPeeringParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IVirtualNetworkPeeringsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual network peerings in a virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IVirtualNetworkPeeringsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworksOperations.cs b/Samples/test/end-to-end/network/Client/VirtualNetworksOperations.cs index 1676ad5e1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworksOperations.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworksOperations.cs @@ -1,1619 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// VirtualNetworksOperations operations. - /// - internal partial class VirtualNetworksOperations : IServiceOperations, IVirtualNetworksOperations - { - /// - /// Initializes a new instance of the VirtualNetworksOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal VirtualNetworksOperations(NetworkClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the NetworkClient - /// - public NetworkClient Client { get; private set; } - - /// - /// Deletes the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified virtual network by resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Expands referenced resources. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("expand", expand); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a virtual network in the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network operation - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAll", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualNetworks").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Checks whether a private IP address is available for use. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The private IP address to be verified. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckIPAddressAvailabilityWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, string ipAddress = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("ipAddress", ipAddress); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckIPAddressAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/CheckIPAddressAvailability").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (ipAddress != null) - { - _queryParameters.Add(string.Format("ipAddress={0}", System.Uri.EscapeDataString(ipAddress))); - } - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified virtual network. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204 && (int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates or updates a virtual network in the specified resource group. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network operation - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (virtualNetworkName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("virtualNetworkName", virtualNetworkName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAllNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse>(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/end-to-end/network/Client/VirtualNetworksOperationsExtensions.cs b/Samples/test/end-to-end/network/Client/VirtualNetworksOperationsExtensions.cs index bb4bad7f1..9d6cafc2c 100644 --- a/Samples/test/end-to-end/network/Client/VirtualNetworksOperationsExtensions.cs +++ b/Samples/test/end-to-end/network/Client/VirtualNetworksOperationsExtensions.cs @@ -1,409 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace ApplicationGateway -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for VirtualNetworksOperations. - /// - public static partial class VirtualNetworksOperationsExtensions - { - /// - /// Deletes the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - public static void Delete(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName) - { - operations.DeleteAsync(resourceGroupName, virtualNetworkName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Gets the specified virtual network by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Expands referenced resources. - /// - public static VirtualNetwork Get(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, string expand = default(string)) - { - return operations.GetAsync(resourceGroupName, virtualNetworkName, expand).GetAwaiter().GetResult(); - } - - /// - /// Gets the specified virtual network by resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Expands referenced resources. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, expand, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates a virtual network in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network operation - /// - public static VirtualNetwork CreateOrUpdate(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters) - { - return operations.CreateOrUpdateAsync(resourceGroupName, virtualNetworkName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a virtual network in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network operation - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// The operations group for this extension method. - /// - public static IPage ListAll(this IVirtualNetworksOperations operations) - { - return operations.ListAllAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllAsync(this IVirtualNetworksOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - public static IPage List(this IVirtualNetworksOperations operations, string resourceGroupName) - { - return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IVirtualNetworksOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Checks whether a private IP address is available for use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The private IP address to be verified. - /// - public static IPAddressAvailabilityResult CheckIPAddressAvailability(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, string ipAddress = default(string)) - { - return operations.CheckIPAddressAvailabilityAsync(resourceGroupName, virtualNetworkName, ipAddress).GetAwaiter().GetResult(); - } - - /// - /// Checks whether a private IP address is available for use. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The private IP address to be verified. - /// - /// - /// The cancellation token. - /// - public static async Task CheckIPAddressAvailabilityAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, string ipAddress = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CheckIPAddressAvailabilityWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, ipAddress, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - public static void BeginDelete(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName) - { - operations.BeginDeleteAsync(resourceGroupName, virtualNetworkName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified virtual network. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// Creates or updates a virtual network in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network operation - /// - public static VirtualNetwork BeginCreateOrUpdate(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters) - { - return operations.BeginCreateOrUpdateAsync(resourceGroupName, virtualNetworkName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates or updates a virtual network in the specified resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group. - /// - /// - /// The name of the virtual network. - /// - /// - /// Parameters supplied to the create or update virtual network operation - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateOrUpdateAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListAllNext(this IVirtualNetworksOperations operations, string nextPageLink) - { - return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual networks in a subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAllNextAsync(this IVirtualNetworksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IVirtualNetworksOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all virtual networks in a resource group. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IVirtualNetworksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-md-bad-syntax/shell/stderr.txt b/Samples/test/error-behavior/openapi-md-bad-syntax/shell/stderr.txt index d0085d94c..21a311a5b 100644 --- a/Samples/test/error-behavior/openapi-md-bad-syntax/shell/stderr.txt +++ b/Samples/test/error-behavior/openapi-md-bad-syntax/shell/stderr.txt @@ -8,3 +8,4 @@ ERROR: Syntax Error Encountered: Syntax error: bad indentation of a mapping entr ERROR: Syntax Error Encountered: Syntax error: incomplete explicit mapping pair; a key node is missed FATAL: Error: [OperationAbortedException] Error occurred. Exiting. FATAL: swagger-document/loader - FAILED +Process() Cancelled due to exception : [OperationAbortedException] Error occurred. Exiting. diff --git a/Samples/test/error-behavior/openapi-yaml-bad-file-reference/shell/stderr.txt b/Samples/test/error-behavior/openapi-yaml-bad-file-reference/shell/stderr.txt index 04f9c099e..df37b86ba 100644 --- a/Samples/test/error-behavior/openapi-yaml-bad-file-reference/shell/stderr.txt +++ b/Samples/test/error-behavior/openapi-yaml-bad-file-reference/shell/stderr.txt @@ -2,3 +2,4 @@ ERROR: Referenced file '/Samples/test/error-behavior/openapi-yaml-bad-file-reference/i-do-not-exist.json' not found FATAL: Error: [OperationAbortedException] Error occurred. Exiting. FATAL: swagger-document/loader - FAILED +Process() Cancelled due to exception : [OperationAbortedException] Error occurred. Exiting. diff --git a/Samples/test/error-behavior/openapi-yaml-bad-type/Client/CowbellFactory.cs b/Samples/test/error-behavior/openapi-yaml-bad-type/Client/CowbellFactory.cs index 84e36ec55..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-bad-type/Client/CowbellFactory.cs +++ b/Samples/test/error-behavior/openapi-yaml-bad-type/Client/CowbellFactory.cs @@ -1,146 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-bad-type/Client/ICowbellFactory.cs b/Samples/test/error-behavior/openapi-yaml-bad-type/Client/ICowbellFactory.cs index 89ba2bcac..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-bad-type/Client/ICowbellFactory.cs +++ b/Samples/test/error-behavior/openapi-yaml-bad-type/Client/ICowbellFactory.cs @@ -1,34 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-bad-type/Client/Models/Cowbell.cs b/Samples/test/error-behavior/openapi-yaml-bad-type/Client/Models/Cowbell.cs index e371b3299..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-bad-type/Client/Models/Cowbell.cs +++ b/Samples/test/error-behavior/openapi-yaml-bad-type/Client/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name, long? id = default(long?)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellFactory.cs b/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellFactory.cs index 5dad7a5ce..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellFactory.cs +++ b/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellFactory.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ICowbellOperations. - /// - public virtual ICowbellOperations Cowbell { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Cowbell = new CowbellOperations(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperations.cs b/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperations.cs index 1c2ee3dee..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperations.cs +++ b/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperations.cs @@ -1,170 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial class CowbellOperations : IServiceOperations, ICowbellOperations - { - /// - /// Initializes a new instance of the CowbellOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellOperations(CowbellFactory client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellFactory - /// - public CowbellFactory Client { get; private set; } - - /// - /// A good description. - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperationsExtensions.cs b/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperationsExtensions.cs index c416f5a46..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperationsExtensions.cs +++ b/Samples/test/error-behavior/openapi-yaml-good/Client/CowbellOperationsExtensions.cs @@ -1,48 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CowbellOperations. - /// - public static partial class CowbellOperationsExtensions - { - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - public static void Add(this ICowbellOperations operations, Cowbell body) - { - operations.AddAsync(body).GetAwaiter().GetResult(); - } - - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task AddAsync(this ICowbellOperations operations, Cowbell body, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellFactory.cs b/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellFactory.cs index ef1b7c4c8..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellFactory.cs +++ b/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellFactory.cs @@ -1,39 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ICowbellOperations. - /// - ICowbellOperations Cowbell { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellOperations.cs b/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellOperations.cs index ea51ebd19..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellOperations.cs +++ b/Samples/test/error-behavior/openapi-yaml-good/Client/ICowbellOperations.cs @@ -1,40 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial interface ICowbellOperations - { - /// - /// A good description. - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/error-behavior/openapi-yaml-good/Client/Models/Cowbell.cs b/Samples/test/error-behavior/openapi-yaml-good/Client/Models/Cowbell.cs index e371b3299..9d6cafc2c 100644 --- a/Samples/test/error-behavior/openapi-yaml-good/Client/Models/Cowbell.cs +++ b/Samples/test/error-behavior/openapi-yaml-good/Client/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Tiny.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name, long? id = default(long?)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/Client/CowbellFactory.cs b/Samples/test/hidden-methods/Client/CowbellFactory.cs index a9a33d6bc..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/Client/CowbellFactory.cs +++ b/Samples/test/hidden-methods/Client/CowbellFactory.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ICowbellOperations. - /// - public virtual ICowbellOperations Cowbell { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Cowbell = new CowbellOperations(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/Client/CowbellOperations.cs b/Samples/test/hidden-methods/Client/CowbellOperations.cs index 4ea43b5c5..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/Client/CowbellOperations.cs +++ b/Samples/test/hidden-methods/Client/CowbellOperations.cs @@ -1,170 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial class CowbellOperations : IServiceOperations, ICowbellOperations - { - /// - /// Initializes a new instance of the CowbellOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellOperations(CowbellFactory client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellFactory - /// - public CowbellFactory Client { get; private set; } - - /// - /// A good description. - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/Client/CowbellOperationsExtensions.cs b/Samples/test/hidden-methods/Client/CowbellOperationsExtensions.cs index a095a7d5f..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/Client/CowbellOperationsExtensions.cs +++ b/Samples/test/hidden-methods/Client/CowbellOperationsExtensions.cs @@ -1,48 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CowbellOperations. - /// - public static partial class CowbellOperationsExtensions - { - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - public static void Add(this ICowbellOperations operations, Cowbell body) - { - operations.AddAsync(body).GetAwaiter().GetResult(); - } - - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task AddAsync(this ICowbellOperations operations, Cowbell body, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/Client/ICowbellFactory.cs b/Samples/test/hidden-methods/Client/ICowbellFactory.cs index a51538028..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/Client/ICowbellFactory.cs +++ b/Samples/test/hidden-methods/Client/ICowbellFactory.cs @@ -1,39 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ICowbellOperations. - /// - ICowbellOperations Cowbell { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/Client/ICowbellOperations.cs b/Samples/test/hidden-methods/Client/ICowbellOperations.cs index aa9a23613..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/Client/ICowbellOperations.cs +++ b/Samples/test/hidden-methods/Client/ICowbellOperations.cs @@ -1,40 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial interface ICowbellOperations - { - /// - /// A good description. - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/Client/Models/Cowbell.cs b/Samples/test/hidden-methods/Client/Models/Cowbell.cs index 8a67cdcd9..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/Client/Models/Cowbell.cs +++ b/Samples/test/hidden-methods/Client/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name, long? id = default(long?)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/ClientFancy/CowbellFactory.cs b/Samples/test/hidden-methods/ClientFancy/CowbellFactory.cs index a9a33d6bc..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/ClientFancy/CowbellFactory.cs +++ b/Samples/test/hidden-methods/ClientFancy/CowbellFactory.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ICowbellOperations. - /// - public virtual ICowbellOperations Cowbell { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Cowbell = new CowbellOperations(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/ClientFancy/CowbellOperations.cs b/Samples/test/hidden-methods/ClientFancy/CowbellOperations.cs index 833ec81f5..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/ClientFancy/CowbellOperations.cs +++ b/Samples/test/hidden-methods/ClientFancy/CowbellOperations.cs @@ -1,170 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial class CowbellOperations : IServiceOperations, ICowbellOperations - { - /// - /// Initializes a new instance of the CowbellOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellOperations(CowbellFactory client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellFactory - /// - public CowbellFactory Client { get; private set; } - - /// - /// A good description. - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - internal async Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/ClientFancy/CowbellOperationsExtensions.cs b/Samples/test/hidden-methods/ClientFancy/CowbellOperationsExtensions.cs index e6e48da4c..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/ClientFancy/CowbellOperationsExtensions.cs +++ b/Samples/test/hidden-methods/ClientFancy/CowbellOperationsExtensions.cs @@ -1,48 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CowbellOperations. - /// - public static partial class CowbellOperationsExtensions - { - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - internal static void Add(this ICowbellOperations operations, Cowbell body) - { - operations.AddAsync(body).GetAwaiter().GetResult(); - } - - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - internal static async Task AddAsync(this ICowbellOperations operations, Cowbell body, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/ClientFancy/ICowbellFactory.cs b/Samples/test/hidden-methods/ClientFancy/ICowbellFactory.cs index a51538028..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/ClientFancy/ICowbellFactory.cs +++ b/Samples/test/hidden-methods/ClientFancy/ICowbellFactory.cs @@ -1,39 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ICowbellOperations. - /// - ICowbellOperations Cowbell { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/ClientFancy/ICowbellOperations.cs b/Samples/test/hidden-methods/ClientFancy/ICowbellOperations.cs index aa9a23613..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/ClientFancy/ICowbellOperations.cs +++ b/Samples/test/hidden-methods/ClientFancy/ICowbellOperations.cs @@ -1,40 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial interface ICowbellOperations - { - /// - /// A good description. - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/hidden-methods/ClientFancy/Models/Cowbell.cs b/Samples/test/hidden-methods/ClientFancy/Models/Cowbell.cs index 8a67cdcd9..9d6cafc2c 100644 --- a/Samples/test/hidden-methods/ClientFancy/Models/Cowbell.cs +++ b/Samples/test/hidden-methods/ClientFancy/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace HiddenMethods.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name, long? id = default(long?)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/Client/CowbellFactory.cs b/Samples/test/remove-methods/Client/CowbellFactory.cs index d83ff31a4..9d6cafc2c 100644 --- a/Samples/test/remove-methods/Client/CowbellFactory.cs +++ b/Samples/test/remove-methods/Client/CowbellFactory.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ICowbellOperations. - /// - public virtual ICowbellOperations Cowbell { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Cowbell = new CowbellOperations(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/Client/CowbellOperations.cs b/Samples/test/remove-methods/Client/CowbellOperations.cs index f8001846a..9d6cafc2c 100644 --- a/Samples/test/remove-methods/Client/CowbellOperations.cs +++ b/Samples/test/remove-methods/Client/CowbellOperations.cs @@ -1,300 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial class CowbellOperations : IServiceOperations, ICowbellOperations - { - /// - /// Initializes a new instance of the CowbellOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellOperations(CowbellFactory client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellFactory - /// - public CowbellFactory Client { get; private set; } - - /// - /// A good description. - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string id = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("id", id); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - List _queryParameters = new List(); - if (id != null) - { - _queryParameters.Add(string.Format("id={0}", System.Uri.EscapeDataString(id))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/Client/CowbellOperationsExtensions.cs b/Samples/test/remove-methods/Client/CowbellOperationsExtensions.cs index 730ccbec1..9d6cafc2c 100644 --- a/Samples/test/remove-methods/Client/CowbellOperationsExtensions.cs +++ b/Samples/test/remove-methods/Client/CowbellOperationsExtensions.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CowbellOperations. - /// - public static partial class CowbellOperationsExtensions - { - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - public static void Add(this ICowbellOperations operations, Cowbell body) - { - operations.AddAsync(body).GetAwaiter().GetResult(); - } - - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task AddAsync(this ICowbellOperations operations, Cowbell body, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// - public static Cowbell Get(this ICowbellOperations operations, string id = default(string)) - { - return operations.GetAsync(id).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ICowbellOperations operations, string id = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/Client/ICowbellFactory.cs b/Samples/test/remove-methods/Client/ICowbellFactory.cs index 54112d770..9d6cafc2c 100644 --- a/Samples/test/remove-methods/Client/ICowbellFactory.cs +++ b/Samples/test/remove-methods/Client/ICowbellFactory.cs @@ -1,39 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ICowbellOperations. - /// - ICowbellOperations Cowbell { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/Client/ICowbellOperations.cs b/Samples/test/remove-methods/Client/ICowbellOperations.cs index b24e6ce81..9d6cafc2c 100644 --- a/Samples/test/remove-methods/Client/ICowbellOperations.cs +++ b/Samples/test/remove-methods/Client/ICowbellOperations.cs @@ -1,55 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial interface ICowbellOperations - { - /// - /// A good description. - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - Task> GetWithHttpMessagesAsync(string id = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/Client/Models/Cowbell.cs b/Samples/test/remove-methods/Client/Models/Cowbell.cs index 20c62464e..9d6cafc2c 100644 --- a/Samples/test/remove-methods/Client/Models/Cowbell.cs +++ b/Samples/test/remove-methods/Client/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name, long? id = default(long?)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/ClientFancy/CowbellFactory.cs b/Samples/test/remove-methods/ClientFancy/CowbellFactory.cs index d83ff31a4..9d6cafc2c 100644 --- a/Samples/test/remove-methods/ClientFancy/CowbellFactory.cs +++ b/Samples/test/remove-methods/ClientFancy/CowbellFactory.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ICowbellOperations. - /// - public virtual ICowbellOperations Cowbell { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Cowbell = new CowbellOperations(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/ClientFancy/CowbellOperations.cs b/Samples/test/remove-methods/ClientFancy/CowbellOperations.cs index 17f2cb557..9d6cafc2c 100644 --- a/Samples/test/remove-methods/ClientFancy/CowbellOperations.cs +++ b/Samples/test/remove-methods/ClientFancy/CowbellOperations.cs @@ -1,178 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial class CowbellOperations : IServiceOperations, ICowbellOperations - { - /// - /// Initializes a new instance of the CowbellOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellOperations(CowbellFactory client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellFactory - /// - public CowbellFactory Client { get; private set; } - - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string id = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("id", id); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - List _queryParameters = new List(); - if (id != null) - { - _queryParameters.Add(string.Format("id={0}", System.Uri.EscapeDataString(id))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/ClientFancy/CowbellOperationsExtensions.cs b/Samples/test/remove-methods/ClientFancy/CowbellOperationsExtensions.cs index 76c40707c..9d6cafc2c 100644 --- a/Samples/test/remove-methods/ClientFancy/CowbellOperationsExtensions.cs +++ b/Samples/test/remove-methods/ClientFancy/CowbellOperationsExtensions.cs @@ -1,45 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CowbellOperations. - /// - public static partial class CowbellOperationsExtensions - { - /// - /// The operations group for this extension method. - /// - /// - /// - public static Cowbell Get(this ICowbellOperations operations, string id = default(string)) - { - return operations.GetAsync(id).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ICowbellOperations operations, string id = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/ClientFancy/ICowbellFactory.cs b/Samples/test/remove-methods/ClientFancy/ICowbellFactory.cs index 54112d770..9d6cafc2c 100644 --- a/Samples/test/remove-methods/ClientFancy/ICowbellFactory.cs +++ b/Samples/test/remove-methods/ClientFancy/ICowbellFactory.cs @@ -1,39 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ICowbellOperations. - /// - ICowbellOperations Cowbell { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/ClientFancy/ICowbellOperations.cs b/Samples/test/remove-methods/ClientFancy/ICowbellOperations.cs index a529f2faf..9d6cafc2c 100644 --- a/Samples/test/remove-methods/ClientFancy/ICowbellOperations.cs +++ b/Samples/test/remove-methods/ClientFancy/ICowbellOperations.cs @@ -1,37 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial interface ICowbellOperations - { - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - Task> GetWithHttpMessagesAsync(string id = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/remove-methods/ClientFancy/Models/Cowbell.cs b/Samples/test/remove-methods/ClientFancy/Models/Cowbell.cs index 20c62464e..9d6cafc2c 100644 --- a/Samples/test/remove-methods/ClientFancy/Models/Cowbell.cs +++ b/Samples/test/remove-methods/ClientFancy/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace RemoveMethods.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name, long? id = default(long?)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/BatchAccountOperations.cs b/Samples/test/shared-response-header-types/Client/BatchAccountOperations.cs index bf4727c5a..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/BatchAccountOperations.cs +++ b/Samples/test/shared-response-header-types/Client/BatchAccountOperations.cs @@ -1,1000 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// BatchAccountOperations operations. - /// - internal partial class BatchAccountOperations : IServiceOperations, IBatchAccountOperations - { - /// - /// Initializes a new instance of the BatchAccountOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal BatchAccountOperations(BatchManagementDummyClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the BatchManagementDummyClient - /// - public BatchManagementDummyClient Client { get; private set; } - - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be updated with - /// the Update Batch Account API. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the region. Batch - /// account names must be between 3 and 24 characters in length and must use - /// only numbers and lowercase letters. This name is used as part of the DNS - /// name that is used to access the Batch service in the region in which the - /// account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, BatchAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send Request - AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Updates the properties of an existing Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// Additional parameters for account update. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, BatchAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (resourceGroupName != null) - { - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); - } - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "accountName", "^[-\\w\\._]+$"); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - object _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, accountName, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets information about the specified Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (resourceGroupName != null) - { - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); - } - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "accountName", "^[-\\w\\._]+$"); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - object _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be updated with - /// the Update Batch Account API. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the region. Batch - /// account names must be between 3 and 24 characters in length and must use - /// only numbers and lowercase letters. This name is used as part of the DNS - /// name that is used to access the Batch service in the region in which the - /// account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, BatchAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (resourceGroupName != null) - { - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); - } - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "accountName", "^[-\\w\\._]+$"); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("parameters", parameters); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(parameters != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - object _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Deletes the specified Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (resourceGroupName != null) - { - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$"); - } - } - if (accountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); - } - if (accountName != null) - { - if (accountName.Length > 24) - { - throw new ValidationException(ValidationRules.MaxLength, "accountName", 24); - } - if (accountName.Length < 3) - { - throw new ValidationException(ValidationRules.MinLength, "accountName", 3); - } - if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[-\\w\\._]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "accountName", "^[-\\w\\._]+$"); - } - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("accountName", accountName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - object _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationHeaderResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/BatchAccountOperationsExtensions.cs b/Samples/test/shared-response-header-types/Client/BatchAccountOperationsExtensions.cs index 0c6502692..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/BatchAccountOperationsExtensions.cs +++ b/Samples/test/shared-response-header-types/Client/BatchAccountOperationsExtensions.cs @@ -1,307 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for BatchAccountOperations. - /// - public static partial class BatchAccountOperationsExtensions - { - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be updated with - /// the Update Batch Account API. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the region. Batch - /// account names must be between 3 and 24 characters in length and must use - /// only numbers and lowercase letters. This name is used as part of the DNS - /// name that is used to access the Batch service in the region in which the - /// account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - public static BatchAccount Create(this IBatchAccountOperations operations, string resourceGroupName, string accountName, BatchAccountCreateParameters parameters) - { - return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be updated with - /// the Update Batch Account API. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the region. Batch - /// account names must be between 3 and 24 characters in length and must use - /// only numbers and lowercase letters. This name is used as part of the DNS - /// name that is used to access the Batch service in the region in which the - /// account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateAsync(this IBatchAccountOperations operations, string resourceGroupName, string accountName, BatchAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates the properties of an existing Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// Additional parameters for account update. - /// - public static BatchAccount Update(this IBatchAccountOperations operations, string resourceGroupName, string accountName, BatchAccountUpdateParameters parameters) - { - return operations.UpdateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Updates the properties of an existing Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// Additional parameters for account update. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IBatchAccountOperations operations, string resourceGroupName, string accountName, BatchAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - public static RetryHeader Delete(this IBatchAccountOperations operations, string resourceGroupName, string accountName) - { - return operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IBatchAccountOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Headers; - } - } - - /// - /// Gets information about the specified Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - public static BatchAccount Get(this IBatchAccountOperations operations, string resourceGroupName, string accountName) - { - return operations.GetAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Gets information about the specified Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IBatchAccountOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be updated with - /// the Update Batch Account API. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the region. Batch - /// account names must be between 3 and 24 characters in length and must use - /// only numbers and lowercase letters. This name is used as part of the DNS - /// name that is used to access the Batch service in the region in which the - /// account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - public static BatchAccount BeginCreate(this IBatchAccountOperations operations, string resourceGroupName, string accountName, BatchAccountCreateParameters parameters) - { - return operations.BeginCreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult(); - } - - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be updated with - /// the Update Batch Account API. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the region. Batch - /// account names must be between 3 and 24 characters in length and must use - /// only numbers and lowercase letters. This name is used as part of the DNS - /// name that is used to access the Batch service in the region in which the - /// account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateAsync(this IBatchAccountOperations operations, string resourceGroupName, string accountName, BatchAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes the specified Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - public static RetryHeader BeginDelete(this IBatchAccountOperations operations, string resourceGroupName, string accountName) - { - return operations.BeginDeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); - } - - /// - /// Deletes the specified Batch account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// The cancellation token. - /// - public static async Task BeginDeleteAsync(this IBatchAccountOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Headers; - } - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/BatchManagementDummyClient.cs b/Samples/test/shared-response-header-types/Client/BatchManagementDummyClient.cs index 585429324..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/BatchManagementDummyClient.cs +++ b/Samples/test/shared-response-header-types/Client/BatchManagementDummyClient.cs @@ -1,313 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - - public partial class BatchManagementDummyClient : ServiceClient, IBatchManagementDummyClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// The Azure subscription ID. This is a GUID-formatted string (e.g. - /// 00000000-0000-0000-0000-000000000000) - /// - public string SubscriptionId { get; set; } - - /// - /// The API version to be used with the HTTP request. - /// - public string ApiVersion { get; private set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Gets the IBatchAccountOperations. - /// - public virtual IBatchAccountOperations BatchAccount { get; private set; } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected BatchManagementDummyClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected BatchManagementDummyClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected BatchManagementDummyClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected BatchManagementDummyClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public BatchManagementDummyClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public BatchManagementDummyClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public BatchManagementDummyClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the BatchManagementDummyClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public BatchManagementDummyClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - BatchAccount = new BatchAccountOperations(this); - BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2017-05-01"; - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/IBatchAccountOperations.cs b/Samples/test/shared-response-header-types/Client/IBatchAccountOperations.cs index b6fa429ee..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/IBatchAccountOperations.cs +++ b/Samples/test/shared-response-header-types/Client/IBatchAccountOperations.cs @@ -1,190 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// BatchAccountOperations operations. - /// - public partial interface IBatchAccountOperations - { - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be - /// updated with the Update Batch Account API. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the - /// region. Batch account names must be between 3 and 24 characters in - /// length and must use only numbers and lowercase letters. This name - /// is used as part of the DNS name that is used to access the Batch - /// service in the region in which the account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, BatchAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Updates the properties of an existing Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// Additional parameters for account update. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, BatchAccountUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets information about the specified Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates a new Batch account with the specified parameters. Existing - /// accounts cannot be updated with this API and should instead be - /// updated with the Update Batch Account API. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// A name for the Batch account which must be unique within the - /// region. Batch account names must be between 3 and 24 characters in - /// length and must use only numbers and lowercase letters. This name - /// is used as part of the DNS name that is used to access the Batch - /// service in the region in which the account is created. For example: - /// http://accountname.region.batch.azure.com/. - /// - /// - /// Additional parameters for account creation. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string accountName, BatchAccountCreateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes the specified Batch account. - /// - /// - /// The name of the resource group that contains the Batch account. - /// - /// - /// The name of the Batch account. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/IBatchManagementDummyClient.cs b/Samples/test/shared-response-header-types/Client/IBatchManagementDummyClient.cs index ae7b60be0..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/IBatchManagementDummyClient.cs +++ b/Samples/test/shared-response-header-types/Client/IBatchManagementDummyClient.cs @@ -1,73 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - - /// - /// - public partial interface IBatchManagementDummyClient : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - ServiceClientCredentials Credentials { get; } - - /// - /// The Azure subscription ID. This is a GUID-formatted string (e.g. - /// 00000000-0000-0000-0000-000000000000) - /// - string SubscriptionId { get; set; } - - /// - /// The API version to be used with the HTTP request. - /// - string ApiVersion { get; } - - /// - /// Gets or sets the preferred language for the response. - /// - string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. - /// - int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. - /// - bool? GenerateClientRequestId { get; set; } - - - /// - /// Gets the IBatchAccountOperations. - /// - IBatchAccountOperations BatchAccount { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/AutoStorageBaseProperties.cs b/Samples/test/shared-response-header-types/Client/Models/AutoStorageBaseProperties.cs index 559e0ccc8..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/AutoStorageBaseProperties.cs +++ b/Samples/test/shared-response-header-types/Client/Models/AutoStorageBaseProperties.cs @@ -1,63 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// The properties related to the auto-storage account. - /// - public partial class AutoStorageBaseProperties - { - /// - /// Initializes a new instance of the AutoStorageBaseProperties class. - /// - public AutoStorageBaseProperties() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the AutoStorageBaseProperties class. - /// - /// The resource ID of the storage - /// account to be used for auto-storage account. - public AutoStorageBaseProperties(string storageAccountId) - { - StorageAccountId = storageAccountId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the resource ID of the storage account to be used for - /// auto-storage account. - /// - [JsonProperty(PropertyName = "storageAccountId")] - public string StorageAccountId { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (StorageAccountId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "StorageAccountId"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/BatchAccount.cs b/Samples/test/shared-response-header-types/Client/Models/BatchAccount.cs index 1696143a4..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/BatchAccount.cs +++ b/Samples/test/shared-response-header-types/Client/Models/BatchAccount.cs @@ -1,82 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Contains information about an Azure Batch account. - /// - [JsonTransformation] - public partial class BatchAccount : Resource - { - /// - /// Initializes a new instance of the BatchAccount class. - /// - public BatchAccount() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BatchAccount class. - /// - /// The ID of the resource. - /// The name of the resource. - /// The type of the resource. - /// The location of the resource. - /// The tags of the resource. - /// The account endpoint used to interact - /// with the Batch service. - /// A reference to the Azure key vault - /// associated with the Batch account. - public BatchAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string accountEndpoint = default(string), KeyVaultReference keyVaultReference = default(KeyVaultReference)) - : base(id, name, type, location, tags) - { - AccountEndpoint = accountEndpoint; - KeyVaultReference = keyVaultReference; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the account endpoint used to interact with the Batch service. - /// - [JsonProperty(PropertyName = "properties.accountEndpoint")] - public string AccountEndpoint { get; private set; } - - /// - /// Gets a reference to the Azure key vault associated with the Batch - /// account. - /// - [JsonProperty(PropertyName = "properties.keyVaultReference")] - public KeyVaultReference KeyVaultReference { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyVaultReference != null) - { - KeyVaultReference.Validate(); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/BatchAccountCreateParameters.cs b/Samples/test/shared-response-header-types/Client/Models/BatchAccountCreateParameters.cs index 1cf14ea5d..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/BatchAccountCreateParameters.cs +++ b/Samples/test/shared-response-header-types/Client/Models/BatchAccountCreateParameters.cs @@ -1,75 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Parameters supplied to the Create operation. - /// - public partial class BatchAccountCreateParameters - { - /// - /// Initializes a new instance of the BatchAccountCreateParameters - /// class. - /// - public BatchAccountCreateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BatchAccountCreateParameters - /// class. - /// - /// The region in which to create the - /// account. - /// The user-specified tags associated with the - /// account. - public BatchAccountCreateParameters(string location, IDictionary tags = default(IDictionary)) - { - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the region in which to create the account. - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; set; } - - /// - /// Gets or sets the user-specified tags associated with the account. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Location == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Location"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/BatchAccountUpdateParameters.cs b/Samples/test/shared-response-header-types/Client/Models/BatchAccountUpdateParameters.cs index 809b87125..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/BatchAccountUpdateParameters.cs +++ b/Samples/test/shared-response-header-types/Client/Models/BatchAccountUpdateParameters.cs @@ -1,52 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Parameters for updating an Azure Batch account. - /// - public partial class BatchAccountUpdateParameters - { - /// - /// Initializes a new instance of the BatchAccountUpdateParameters - /// class. - /// - public BatchAccountUpdateParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the BatchAccountUpdateParameters - /// class. - /// - /// The user-specified tags associated with the - /// account. - public BatchAccountUpdateParameters(IDictionary tags = default(IDictionary)) - { - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the user-specified tags associated with the account. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/KeyVaultReference.cs b/Samples/test/shared-response-header-types/Client/Models/KeyVaultReference.cs index b78c31687..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/KeyVaultReference.cs +++ b/Samples/test/shared-response-header-types/Client/Models/KeyVaultReference.cs @@ -1,77 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// Identifies the Azure key vault associated with a Batch account. - /// - public partial class KeyVaultReference - { - /// - /// Initializes a new instance of the KeyVaultReference class. - /// - public KeyVaultReference() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the KeyVaultReference class. - /// - /// The resource ID of the Azure key vault associated - /// with the Batch account. - /// The URL of the Azure key vault associated with - /// the Batch account. - public KeyVaultReference(string id, string url) - { - Id = id; - Url = url; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the resource ID of the Azure key vault associated with - /// the Batch account. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - /// - /// Gets or sets the URL of the Azure key vault associated with the - /// Batch account. - /// - [JsonProperty(PropertyName = "url")] - public string Url { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Id == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Id"); - } - if (Url == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Url"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/Operation.cs b/Samples/test/shared-response-header-types/Client/Models/Operation.cs index 96b35ea05..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/Operation.cs +++ b/Samples/test/shared-response-header-types/Client/Models/Operation.cs @@ -1,76 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// A REST API operation - /// - public partial class Operation - { - /// - /// Initializes a new instance of the Operation class. - /// - public Operation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Operation class. - /// - /// The operation name. - /// The object that describes the - /// operation. - /// The intended executor of the - /// operation. - /// Properties of the operation. - public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay), string origin = default(string), object properties = default(object)) - { - Name = name; - Display = display; - Origin = origin; - Properties = properties; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the operation name. - /// - /// - /// This is of the format {provider}/{resource}/{operation} - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets the object that describes the operation. - /// - [JsonProperty(PropertyName = "display")] - public OperationDisplay Display { get; set; } - - /// - /// Gets or sets the intended executor of the operation. - /// - [JsonProperty(PropertyName = "origin")] - public string Origin { get; set; } - - /// - /// Gets or sets properties of the operation. - /// - [JsonProperty(PropertyName = "properties")] - public object Properties { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/OperationDisplay.cs b/Samples/test/shared-response-header-types/Client/Models/OperationDisplay.cs index 45bac23fd..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/OperationDisplay.cs +++ b/Samples/test/shared-response-header-types/Client/Models/OperationDisplay.cs @@ -1,77 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// The object that describes the operation. - /// - public partial class OperationDisplay - { - /// - /// Initializes a new instance of the OperationDisplay class. - /// - public OperationDisplay() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the OperationDisplay class. - /// - /// Friendly name of the resource - /// provider. - /// The operation type. - /// The resource type on which the operation is - /// performed. - /// The friendly name of the - /// operation - public OperationDisplay(string provider = default(string), string operation = default(string), string resource = default(string), string description = default(string)) - { - Provider = provider; - Operation = operation; - Resource = resource; - Description = description; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets friendly name of the resource provider. - /// - [JsonProperty(PropertyName = "provider")] - public string Provider { get; set; } - - /// - /// Gets or sets the operation type. - /// - /// - /// For example: read, write, delete, or listKeys/action - /// - [JsonProperty(PropertyName = "operation")] - public string Operation { get; set; } - - /// - /// Gets or sets the resource type on which the operation is performed. - /// - [JsonProperty(PropertyName = "resource")] - public string Resource { get; set; } - - /// - /// Gets or sets the friendly name of the operation - /// - [JsonProperty(PropertyName = "description")] - public string Description { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/Resource.cs b/Samples/test/shared-response-header-types/Client/Models/Resource.cs index 8097a2a30..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/Resource.cs +++ b/Samples/test/shared-response-header-types/Client/Models/Resource.cs @@ -1,83 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A definition of an Azure resource. - /// - public partial class Resource : IResource - { - /// - /// Initializes a new instance of the Resource class. - /// - public Resource() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Resource class. - /// - /// The ID of the resource. - /// The name of the resource. - /// The type of the resource. - /// The location of the resource. - /// The tags of the resource. - public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) - { - Id = id; - Name = name; - Type = type; - Location = location; - Tags = tags; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the ID of the resource. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets the name of the resource. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets the type of the resource. - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; private set; } - - /// - /// Gets the location of the resource. - /// - [JsonProperty(PropertyName = "location")] - public string Location { get; private set; } - - /// - /// Gets the tags of the resource. - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; private set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/shared-response-header-types/Client/Models/RetryHeader.cs b/Samples/test/shared-response-header-types/Client/Models/RetryHeader.cs index dbf5f2e13..9d6cafc2c 100644 --- a/Samples/test/shared-response-header-types/Client/Models/RetryHeader.cs +++ b/Samples/test/shared-response-header-types/Client/Models/RetryHeader.cs @@ -1,58 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace SharedHeaders.Models -{ - using Newtonsoft.Json; - using System.Linq; - - public partial class RetryHeader - { - /// - /// Initializes a new instance of the RetryHeader class. - /// - public RetryHeader() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the RetryHeader class. - /// - /// The URL of the resource used to check the - /// status of the asynchronous operation. - /// Suggested delay to check the status of the - /// asynchronous operation. The value is an integer that specifies the - /// delay in seconds. - public RetryHeader(string location = default(string), int? retryAfter = default(int?)) - { - Location = location; - RetryAfter = retryAfter; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the URL of the resource used to check the status of - /// the asynchronous operation. - /// - [JsonProperty(PropertyName = "Location")] - public string Location { get; set; } - - /// - /// Gets or sets suggested delay to check the status of the - /// asynchronous operation. The value is an integer that specifies the - /// delay in seconds. - /// - [JsonProperty(PropertyName = "Retry-After")] - public int? RetryAfter { get; set; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/CowbellModerator.cs b/Samples/test/stream-with-content-type/ClientCSharp/CowbellModerator.cs index 2a4428865..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/CowbellModerator.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/CowbellModerator.cs @@ -1,155 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - public partial class CowbellModerator : ServiceClient, ICowbellModerator - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the IImage. - /// - public virtual IImage Image { get; private set; } - - /// - /// Gets the IText. - /// - public virtual IText Text { get; private set; } - - /// - /// Initializes a new instance of the CowbellModerator class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellModerator(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellModerator class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellModerator(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellModerator class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellModerator(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellModerator class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellModerator(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Image = new Image(this); - Text = new Text(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/ICowbellModerator.cs b/Samples/test/stream-with-content-type/ClientCSharp/ICowbellModerator.cs index 4cf3a022b..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/ICowbellModerator.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/ICowbellModerator.cs @@ -1,43 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Models; - using Newtonsoft.Json; - - /// - /// - public partial interface ICowbellModerator : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the IImage. - /// - IImage Image { get; } - - /// - /// Gets the IText. - /// - IText Text { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/IImage.cs b/Samples/test/stream-with-content-type/ClientCSharp/IImage.cs index 7bdc714fc..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/IImage.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/IImage.cs @@ -1,103 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Image operations. - /// - public partial interface IImage - { - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: - /// 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AWithHttpMessagesAsync(Stream image, ImageType imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: - /// 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BWithHttpMessagesAsync(Stream image, ImageType imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: - /// 'image/png', 'image/tiff' - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task CWithHttpMessagesAsync(Stream image, ImageTypeRestricted imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: - /// 'image/png', 'image/tiff' - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task DWithHttpMessagesAsync(Stream image, string imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/IText.cs b/Samples/test/stream-with-content-type/ClientCSharp/IText.cs index 13292d4e7..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/IText.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/IText.cs @@ -1,61 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Text operations. - /// - public partial interface IText - { - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AWithHttpMessagesAsync(Stream text, string contentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task BWithHttpMessagesAsync(Stream text, string contentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/Image.cs b/Samples/test/stream-with-content-type/ClientCSharp/Image.cs index 569211d64..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/Image.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/Image.cs @@ -1,548 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Image operations. - /// - public partial class Image : IServiceOperations, IImage - { - /// - /// Initializes a new instance of the Image class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Image(CowbellModerator client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellModerator - /// - public CowbellModerator Client { get; private set; } - - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/gif', - /// 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AWithHttpMessagesAsync(Stream image, ImageType imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (image == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "image"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("image", image); - tracingParameters.Add("imageContentType", imageContentType); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "A", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "ProcessImage/FunctionA").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(image == null) - { - throw new System.ArgumentNullException("image"); - } - if (image != null && image != Stream.Null) - { - _httpRequest.Content = new StreamContent(image); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(imageContentType.ToSerializedValue()); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/gif', - /// 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BWithHttpMessagesAsync(Stream image, ImageType imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (image == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "image"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("image", image); - tracingParameters.Add("imageContentType", imageContentType); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "B", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "ProcessImage/FunctionB").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(image == null) - { - throw new System.ArgumentNullException("image"); - } - if (image != null && image != Stream.Null) - { - _httpRequest.Content = new StreamContent(image); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(imageContentType.ToSerializedValue()); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/png', - /// 'image/tiff' - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task CWithHttpMessagesAsync(Stream image, ImageTypeRestricted imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (image == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "image"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("image", image); - tracingParameters.Add("imageContentType", imageContentType); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "C", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "ProcessImage/FunctionC").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(image == null) - { - throw new System.ArgumentNullException("image"); - } - if (image != null && image != Stream.Null) - { - _httpRequest.Content = new StreamContent(image); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(imageContentType.ToSerializedValue()); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/png', - /// 'image/tiff' - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task DWithHttpMessagesAsync(Stream image, string imageContentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (image == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "image"); - } - if (imageContentType == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "imageContentType"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("image", image); - tracingParameters.Add("imageContentType", imageContentType); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "D", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "ProcessImage/FunctionD").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(image == null) - { - throw new System.ArgumentNullException("image"); - } - if (image != null && image != Stream.Null) - { - _httpRequest.Content = new StreamContent(image); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(imageContentType.ToSerializedValue()); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/ImageExtensions.cs b/Samples/test/stream-with-content-type/ClientCSharp/ImageExtensions.cs index 3dac6b180..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/ImageExtensions.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/ImageExtensions.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Models; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Image. - /// - public static partial class ImageExtensions - { - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/gif', - /// 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - public static void A(this IImage operations, Stream image, ImageType imageContentType) - { - operations.AAsync(image, imageContentType).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/gif', - /// 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - /// - /// The cancellation token. - /// - public static async Task AAsync(this IImage operations, Stream image, ImageType imageContentType, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AWithHttpMessagesAsync(image, imageContentType, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/gif', - /// 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - public static void B(this IImage operations, Stream image, ImageType imageContentType) - { - operations.BAsync(image, imageContentType).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/gif', - /// 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - /// - /// - /// The cancellation token. - /// - public static async Task BAsync(this IImage operations, Stream image, ImageType imageContentType, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BWithHttpMessagesAsync(image, imageContentType, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/png', - /// 'image/tiff' - /// - public static void C(this IImage operations, Stream image, ImageTypeRestricted imageContentType) - { - operations.CAsync(image, imageContentType).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/png', - /// 'image/tiff' - /// - /// - /// The cancellation token. - /// - public static async Task CAsync(this IImage operations, Stream image, ImageTypeRestricted imageContentType, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CWithHttpMessagesAsync(image, imageContentType, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/png', - /// 'image/tiff' - /// - public static void D(this IImage operations, Stream image, string imageContentType) - { - operations.DAsync(image, imageContentType).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// An image stream. - /// - /// - /// The content type of the image. Possible values include: 'image/png', - /// 'image/tiff' - /// - /// - /// The cancellation token. - /// - public static async Task DAsync(this IImage operations, Stream image, string imageContentType, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DWithHttpMessagesAsync(image, imageContentType, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/Models/ContentTypes.cs b/Samples/test/stream-with-content-type/ClientCSharp/Models/ContentTypes.cs index 14af19be8..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/Models/ContentTypes.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/Models/ContentTypes.cs @@ -1,19 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType.Models -{ - - /// - /// Defines values for ContentTypes. - /// - public static class ContentTypes - { - public const string TextPlain = "text/plain"; - public const string TextJson = "text/json"; - public const string TextXml = "text/xml"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageType.cs b/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageType.cs index 0c17c9749..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageType.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageType.cs @@ -1,74 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ImageType. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ImageType - { - [EnumMember(Value = "image/gif")] - ImageGif, - [EnumMember(Value = "image/jpeg")] - ImageJpeg, - [EnumMember(Value = "image/png")] - ImagePng, - [EnumMember(Value = "image/bmp")] - ImageBmp, - [EnumMember(Value = "image/tiff")] - ImageTiff - } - internal static class ImageTypeEnumExtension - { - internal static string ToSerializedValue(this ImageType? value) - { - return value == null ? null : ((ImageType)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ImageType value) - { - switch( value ) - { - case ImageType.ImageGif: - return "image/gif"; - case ImageType.ImageJpeg: - return "image/jpeg"; - case ImageType.ImagePng: - return "image/png"; - case ImageType.ImageBmp: - return "image/bmp"; - case ImageType.ImageTiff: - return "image/tiff"; - } - return null; - } - - internal static ImageType? ParseImageType(this string value) - { - switch( value ) - { - case "image/gif": - return ImageType.ImageGif; - case "image/jpeg": - return ImageType.ImageJpeg; - case "image/png": - return ImageType.ImagePng; - case "image/bmp": - return ImageType.ImageBmp; - case "image/tiff": - return ImageType.ImageTiff; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestricted.cs b/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestricted.cs index 85c3c31c5..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestricted.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestricted.cs @@ -1,56 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for ImageTypeRestricted. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum ImageTypeRestricted - { - [EnumMember(Value = "image/png")] - ImagePng, - [EnumMember(Value = "image/tiff")] - ImageTiff - } - internal static class ImageTypeRestrictedEnumExtension - { - internal static string ToSerializedValue(this ImageTypeRestricted? value) - { - return value == null ? null : ((ImageTypeRestricted)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this ImageTypeRestricted value) - { - switch( value ) - { - case ImageTypeRestricted.ImagePng: - return "image/png"; - case ImageTypeRestricted.ImageTiff: - return "image/tiff"; - } - return null; - } - - internal static ImageTypeRestricted? ParseImageTypeRestricted(this string value) - { - switch( value ) - { - case "image/png": - return ImageTypeRestricted.ImagePng; - case "image/tiff": - return ImageTypeRestricted.ImageTiff; - } - return null; - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestrictedStrings.cs b/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestrictedStrings.cs index 797b57ae6..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestrictedStrings.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/Models/ImageTypeRestrictedStrings.cs @@ -1,18 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType.Models -{ - - /// - /// Defines values for ImageTypeRestrictedStrings. - /// - public static class ImageTypeRestrictedStrings - { - public const string ImagePng = "image/png"; - public const string ImageTiff = "image/tiff"; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/Text.cs b/Samples/test/stream-with-content-type/ClientCSharp/Text.cs index a49769efe..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/Text.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/Text.cs @@ -1,302 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Text operations. - /// - public partial class Text : IServiceOperations, IText - { - /// - /// Initializes a new instance of the Text class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Text(CowbellModerator client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellModerator - /// - public CowbellModerator Client { get; private set; } - - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AWithHttpMessagesAsync(Stream text, string contentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (text == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "text"); - } - if (contentType == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "contentType"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("text", text); - tracingParameters.Add("contentType", contentType); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "A", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "ProcessImage/FunctionTA").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(text == null) - { - throw new System.ArgumentNullException("text"); - } - if (text != null && text != Stream.Null) - { - _httpRequest.Content = new StreamContent(text); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(contentType.ToSerializedValue()); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task BWithHttpMessagesAsync(Stream text, string contentType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (text == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "text"); - } - if (contentType == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "contentType"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("text", text); - tracingParameters.Add("contentType", contentType); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "B", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "ProcessImage/FunctionTB").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(text == null) - { - throw new System.ArgumentNullException("text"); - } - if (text != null && text != Stream.Null) - { - _httpRequest.Content = new StreamContent(text); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(contentType.ToSerializedValue()); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientCSharp/TextExtensions.cs b/Samples/test/stream-with-content-type/ClientCSharp/TextExtensions.cs index a3861687a..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientCSharp/TextExtensions.cs +++ b/Samples/test/stream-with-content-type/ClientCSharp/TextExtensions.cs @@ -1,82 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace StreamWithContentType -{ - using Models; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Text. - /// - public static partial class TextExtensions - { - /// - /// The operations group for this extension method. - /// - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - public static void A(this IText operations, Stream text, string contentType) - { - operations.AAsync(text, contentType).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - /// - /// The cancellation token. - /// - public static async Task AAsync(this IText operations, Stream text, string contentType, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AWithHttpMessagesAsync(text, contentType, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - public static void B(this IText operations, Stream text, string contentType) - { - operations.BAsync(text, contentType).GetAwaiter().GetResult(); - } - - /// - /// The operations group for this extension method. - /// - /// - /// A text stream. - /// - /// - /// The content type of the image. - /// - /// - /// The cancellation token. - /// - public static async Task BAsync(this IText operations, Stream text, string contentType, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.BWithHttpMessagesAsync(text, contentType, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientGo/client.go b/Samples/test/stream-with-content-type/ClientGo/client.go index d4bc0cba8..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientGo/client.go +++ b/Samples/test/stream-with-content-type/ClientGo/client.go @@ -1,36 +1 @@ -// Package implements the Azure ARM service API version 1.0. -// -// -package - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -const ( - // DefaultBaseURI is the default URI used for the service - DefaultBaseURI = "https://localhost" -) - -// ManagementClient is the base client for . -type ManagementClient struct { - autorest.Client - BaseURI string - } - -// New creates an instance of the ManagementClient client. -func New()ManagementClient { - return NewWithBaseURI(DefaultBaseURI, ) -} - - // NewWithBaseURI creates an instance of the ManagementClient client. - func NewWithBaseURI(baseURI string, ) ManagementClient { - return ManagementClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - } - } - +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientGo/imagegroup.go b/Samples/test/stream-with-content-type/ClientGo/imagegroup.go index 90e714e3d..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientGo/imagegroup.go +++ b/Samples/test/stream-with-content-type/ClientGo/imagegroup.go @@ -1,246 +1 @@ -package - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" - "io" -) - -// ImageGroupClient is the client for the ImageGroup methods of the service. -type ImageGroupClient struct { - ManagementClient -} -// NewImageGroupClient creates an instance of the ImageGroupClient client. -func NewImageGroupClient() ImageGroupClient { - return NewImageGroupClientWithBaseURI(DefaultBaseURI, ) - } - -// NewImageGroupClientWithBaseURI creates an instance of the ImageGroupClient client. - func NewImageGroupClientWithBaseURI(baseURI string, ) ImageGroupClient { - return ImageGroupClient{ NewWithBaseURI(baseURI, )} - } - -// AMethod sends the a method request. -// -// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure -// closure when receiving an error.imageContentType is the content type of the image. -func (client ImageGroupClient) AMethod(imageParameter io.ReadCloser, imageContentType ImageTypeEnum) (result autorest.Response, err error) { - req, err := client.AMethodPreparer(imageParameter, imageContentType) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "AMethod", nil , "Failure preparing request") - return - } - - resp, err := client.AMethodSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "AMethod", resp, "Failure sending request") - return - } - - result, err = client.AMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "AMethod", resp, "Failure responding to request") - } - - return -} - -// AMethodPreparer prepares the AMethod request. -func (client ImageGroupClient) AMethodPreparer(imageParameter io.ReadCloser, imageContentType ImageTypeEnum) (*http.Request, error) { - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/ProcessImage/FunctionA"), - autorest.WithFile(imageParameter), - autorest.WithHeader("Content-Type",autorest.String(imageContentType))) - return preparer.Prepare(&http.Request{}) -} - -// AMethodSender sends the AMethod request. The method will close the -// http.Response Body if it receives an error. -func (client ImageGroupClient) AMethodSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// AMethodResponder handles the response to the AMethod request. The method always -// closes the http.Response Body. -func (client ImageGroupClient) AMethodResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// BMethod sends the b method request. -// -// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure -// closure when receiving an error.imageContentType is the content type of the image. -func (client ImageGroupClient) BMethod(imageParameter io.ReadCloser, imageContentType ImageTypeEnum) (result autorest.Response, err error) { - req, err := client.BMethodPreparer(imageParameter, imageContentType) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "BMethod", nil , "Failure preparing request") - return - } - - resp, err := client.BMethodSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "BMethod", resp, "Failure sending request") - return - } - - result, err = client.BMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "BMethod", resp, "Failure responding to request") - } - - return -} - -// BMethodPreparer prepares the BMethod request. -func (client ImageGroupClient) BMethodPreparer(imageParameter io.ReadCloser, imageContentType ImageTypeEnum) (*http.Request, error) { - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/ProcessImage/FunctionB"), - autorest.WithFile(imageParameter), - autorest.WithHeader("Content-Type",autorest.String(imageContentType))) - return preparer.Prepare(&http.Request{}) -} - -// BMethodSender sends the BMethod request. The method will close the -// http.Response Body if it receives an error. -func (client ImageGroupClient) BMethodSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// BMethodResponder handles the response to the BMethod request. The method always -// closes the http.Response Body. -func (client ImageGroupClient) BMethodResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// CMethod sends the c method request. -// -// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure -// closure when receiving an error.imageContentType is the content type of the image. -func (client ImageGroupClient) CMethod(imageParameter io.ReadCloser, imageContentType ImageTypeRestrictedEnum) (result autorest.Response, err error) { - req, err := client.CMethodPreparer(imageParameter, imageContentType) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "CMethod", nil , "Failure preparing request") - return - } - - resp, err := client.CMethodSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "CMethod", resp, "Failure sending request") - return - } - - result, err = client.CMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "CMethod", resp, "Failure responding to request") - } - - return -} - -// CMethodPreparer prepares the CMethod request. -func (client ImageGroupClient) CMethodPreparer(imageParameter io.ReadCloser, imageContentType ImageTypeRestrictedEnum) (*http.Request, error) { - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/ProcessImage/FunctionC"), - autorest.WithFile(imageParameter), - autorest.WithHeader("Content-Type",autorest.String(imageContentType))) - return preparer.Prepare(&http.Request{}) -} - -// CMethodSender sends the CMethod request. The method will close the -// http.Response Body if it receives an error. -func (client ImageGroupClient) CMethodSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// CMethodResponder handles the response to the CMethod request. The method always -// closes the http.Response Body. -func (client ImageGroupClient) CMethodResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// DMethod sends the d method request. -// -// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure -// closure when receiving an error.imageContentType is the content type of the image. -func (client ImageGroupClient) DMethod(imageParameter io.ReadCloser, imageContentType ImageTypeRestrictedStringsEnum) (result autorest.Response, err error) { - req, err := client.DMethodPreparer(imageParameter, imageContentType) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "DMethod", nil , "Failure preparing request") - return - } - - resp, err := client.DMethodSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "DMethod", resp, "Failure sending request") - return - } - - result, err = client.DMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, ".ImageGroupClient", "DMethod", resp, "Failure responding to request") - } - - return -} - -// DMethodPreparer prepares the DMethod request. -func (client ImageGroupClient) DMethodPreparer(imageParameter io.ReadCloser, imageContentType ImageTypeRestrictedStringsEnum) (*http.Request, error) { - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/ProcessImage/FunctionD"), - autorest.WithFile(imageParameter), - autorest.WithHeader("Content-Type",autorest.String(imageContentType))) - return preparer.Prepare(&http.Request{}) -} - -// DMethodSender sends the DMethod request. The method will close the -// http.Response Body if it receives an error. -func (client ImageGroupClient) DMethodSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// DMethodResponder handles the response to the DMethod request. The method always -// closes the http.Response Body. -func (client ImageGroupClient) DMethodResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientGo/models.go b/Samples/test/stream-with-content-type/ClientGo/models.go index 3ea329883..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientGo/models.go +++ b/Samples/test/stream-with-content-type/ClientGo/models.go @@ -1,57 +1 @@ -package - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// ContentTypesEnum enumerates the values for content types enum. -type ContentTypesEnum string - -const ( -// Textjson specifies the textjson state for content types enum. -Textjson ContentTypesEnum = "text/json" -// Textplain specifies the textplain state for content types enum. -Textplain ContentTypesEnum = "text/plain" -// Textxml specifies the textxml state for content types enum. -Textxml ContentTypesEnum = "text/xml" -) - -// ImageTypeEnum enumerates the values for image type enum. -type ImageTypeEnum string - -const ( -// Imagebmp specifies the imagebmp state for image type enum. -Imagebmp ImageTypeEnum = "image/bmp" -// Imagegif specifies the imagegif state for image type enum. -Imagegif ImageTypeEnum = "image/gif" -// Imagejpeg specifies the imagejpeg state for image type enum. -Imagejpeg ImageTypeEnum = "image/jpeg" -// Imagepng specifies the imagepng state for image type enum. -Imagepng ImageTypeEnum = "image/png" -// Imagetiff specifies the imagetiff state for image type enum. -Imagetiff ImageTypeEnum = "image/tiff" -) - -// ImageTypeRestrictedEnum enumerates the values for image type restricted enum. -type ImageTypeRestrictedEnum string - -const ( -// ImageTypeRestrictedEnumImagepng specifies the image type restricted enum imagepng state for image type restricted -// enum. -ImageTypeRestrictedEnumImagepng ImageTypeRestrictedEnum = "image/png" -// ImageTypeRestrictedEnumImagetiff specifies the image type restricted enum imagetiff state for image type restricted -// enum. -ImageTypeRestrictedEnumImagetiff ImageTypeRestrictedEnum = "image/tiff" -) - -// ImageTypeRestrictedStringsEnum enumerates the values for image type restricted strings enum. -type ImageTypeRestrictedStringsEnum string - -const ( -// ImageTypeRestrictedStringsEnumImagepng specifies the image type restricted strings enum imagepng state for image -// type restricted strings enum. -ImageTypeRestrictedStringsEnumImagepng ImageTypeRestrictedStringsEnum = "image/png" -// ImageTypeRestrictedStringsEnumImagetiff specifies the image type restricted strings enum imagetiff state for image -// type restricted strings enum. -ImageTypeRestrictedStringsEnumImagetiff ImageTypeRestrictedStringsEnum = "image/tiff" -) - +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientGo/textgroup.go b/Samples/test/stream-with-content-type/ClientGo/textgroup.go index 0c1eb433f..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientGo/textgroup.go +++ b/Samples/test/stream-with-content-type/ClientGo/textgroup.go @@ -1,136 +1 @@ -package - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" - "io" -) - -// TextGroupClient is the client for the TextGroup methods of the service. -type TextGroupClient struct { - ManagementClient -} -// NewTextGroupClient creates an instance of the TextGroupClient client. -func NewTextGroupClient() TextGroupClient { - return NewTextGroupClientWithBaseURI(DefaultBaseURI, ) - } - -// NewTextGroupClientWithBaseURI creates an instance of the TextGroupClient client. - func NewTextGroupClientWithBaseURI(baseURI string, ) TextGroupClient { - return TextGroupClient{ NewWithBaseURI(baseURI, )} - } - -// AMethod sends the a method request. -// -// textParameter is a text stream. textParameter will be closed upon successful return. Callers should ensure closure -// when receiving an error.contentType is the content type of the image. -func (client TextGroupClient) AMethod(textParameter io.ReadCloser, contentType string) (result autorest.Response, err error) { - req, err := client.AMethodPreparer(textParameter, contentType) - if err != nil { - err = autorest.NewErrorWithError(err, ".TextGroupClient", "AMethod", nil , "Failure preparing request") - return - } - - resp, err := client.AMethodSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, ".TextGroupClient", "AMethod", resp, "Failure sending request") - return - } - - result, err = client.AMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, ".TextGroupClient", "AMethod", resp, "Failure responding to request") - } - - return -} - -// AMethodPreparer prepares the AMethod request. -func (client TextGroupClient) AMethodPreparer(textParameter io.ReadCloser, contentType string) (*http.Request, error) { - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/ProcessImage/FunctionTA"), - autorest.WithFile(textParameter), - autorest.WithHeader("Content-Type",autorest.String(contentType))) - return preparer.Prepare(&http.Request{}) -} - -// AMethodSender sends the AMethod request. The method will close the -// http.Response Body if it receives an error. -func (client TextGroupClient) AMethodSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// AMethodResponder handles the response to the AMethod request. The method always -// closes the http.Response Body. -func (client TextGroupClient) AMethodResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// BMethod sends the b method request. -// -// textParameter is a text stream. textParameter will be closed upon successful return. Callers should ensure closure -// when receiving an error.contentType is the content type of the image. -func (client TextGroupClient) BMethod(textParameter io.ReadCloser, contentType string) (result autorest.Response, err error) { - req, err := client.BMethodPreparer(textParameter, contentType) - if err != nil { - err = autorest.NewErrorWithError(err, ".TextGroupClient", "BMethod", nil , "Failure preparing request") - return - } - - resp, err := client.BMethodSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, ".TextGroupClient", "BMethod", resp, "Failure sending request") - return - } - - result, err = client.BMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, ".TextGroupClient", "BMethod", resp, "Failure responding to request") - } - - return -} - -// BMethodPreparer prepares the BMethod request. -func (client TextGroupClient) BMethodPreparer(textParameter io.ReadCloser, contentType string) (*http.Request, error) { - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/ProcessImage/FunctionTB"), - autorest.WithFile(textParameter), - autorest.WithHeader("Content-Type",autorest.String(contentType))) - return preparer.Prepare(&http.Request{}) -} - -// BMethodSender sends the BMethod request. The method will close the -// http.Response Body if it receives an error. -func (client TextGroupClient) BMethodSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// BMethodResponder handles the response to the BMethod request. The method always -// closes the http.Response Body. -func (client TextGroupClient) BMethodResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientGo/version.go b/Samples/test/stream-with-content-type/ClientGo/version.go index 22becfaf7..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientGo/version.go +++ b/Samples/test/stream-with-content-type/ClientGo/version.go @@ -1,15 +1 @@ -package - -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/0.0.0 arm-/1.0" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return "0.0.0" -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/CowbellModerator.java b/Samples/test/stream-with-content-type/ClientJava/CowbellModerator.java index b7198a8c1..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/CowbellModerator.java +++ b/Samples/test/stream-with-content-type/ClientJava/CowbellModerator.java @@ -1,39 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype; - -import com.microsoft.rest.RestClient; - -/** - * The interface for CowbellModerator class. - */ -public interface CowbellModerator { - /** - * Gets the REST client. - * - * @return the {@link RestClient} object. - */ - RestClient restClient(); - - /** - * The default base URL. - */ - String DEFAULT_BASE_URL = "https://localhost"; - - /** - * Gets the Images object to access its operations. - * @return the Images object. - */ - Images images(); - - /** - * Gets the Texts object to access its operations. - * @return the Texts object. - */ - Texts texts(); - -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/Images.java b/Samples/test/stream-with-content-type/ClientJava/Images.java index 1bfae325b..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/Images.java +++ b/Samples/test/stream-with-content-type/ClientJava/Images.java @@ -1,176 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype; - -import .models.ImageType; -import .models.ImageTypeRestricted; -import .models.ImageTypeRestrictedStrings; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Images. - */ -public interface Images { - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void a(byte[] image, ImageType imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture aAsync(byte[] image, ImageType imageContentType, final ServiceCallback serviceCallback); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable aAsync(byte[] image, ImageType imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> aWithServiceResponseAsync(byte[] image, ImageType imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void b(byte[] image, ImageType imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture bAsync(byte[] image, ImageType imageContentType, final ServiceCallback serviceCallback); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable bAsync(byte[] image, ImageType imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> bWithServiceResponseAsync(byte[] image, ImageType imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void c(byte[] image, ImageTypeRestricted imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture cAsync(byte[] image, ImageTypeRestricted imageContentType, final ServiceCallback serviceCallback); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable cAsync(byte[] image, ImageTypeRestricted imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> cWithServiceResponseAsync(byte[] image, ImageTypeRestricted imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void d(byte[] image, ImageTypeRestrictedStrings imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture dAsync(byte[] image, ImageTypeRestrictedStrings imageContentType, final ServiceCallback serviceCallback); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable dAsync(byte[] image, ImageTypeRestrictedStrings imageContentType); - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> dWithServiceResponseAsync(byte[] image, ImageTypeRestrictedStrings imageContentType); - -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/Texts.java b/Samples/test/stream-with-content-type/ClientJava/Texts.java index 2c7f522c7..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/Texts.java +++ b/Samples/test/stream-with-content-type/ClientJava/Texts.java @@ -1,97 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype; - -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.IOException; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Texts. - */ -public interface Texts { - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void a(byte[] text, String contentType); - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture aAsync(byte[] text, String contentType, final ServiceCallback serviceCallback); - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable aAsync(byte[] text, String contentType); - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> aWithServiceResponseAsync(byte[] text, String contentType); - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void b(byte[] text, String contentType); - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - ServiceFuture bAsync(byte[] text, String contentType, final ServiceCallback serviceCallback); - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable bAsync(byte[] text, String contentType); - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - Observable> bWithServiceResponseAsync(byte[] text, String contentType); - -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/implementation/CowbellModeratorImpl.java b/Samples/test/stream-with-content-type/ClientJava/implementation/CowbellModeratorImpl.java index e4a10617c..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/implementation/CowbellModeratorImpl.java +++ b/Samples/test/stream-with-content-type/ClientJava/implementation/CowbellModeratorImpl.java @@ -1,102 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype.implementation; - -import .CowbellModerator; -import .Images; -import .Texts; -import com.microsoft.rest.ServiceClient; -import com.microsoft.rest.RestClient; -import okhttp3.OkHttpClient; -import retrofit2.Retrofit; - -/** - * Initializes a new instance of the CowbellModerator class. - */ -public class CowbellModeratorImpl extends ServiceClient implements CowbellModerator { - - /** - * The Images object to access its operations. - */ - private Images images; - - /** - * Gets the Images object to access its operations. - * @return the Images object. - */ - public Images images() { - return this.images; - } - - /** - * The Texts object to access its operations. - */ - private Texts texts; - - /** - * Gets the Texts object to access its operations. - * @return the Texts object. - */ - public Texts texts() { - return this.texts; - } - - /** - * Initializes an instance of CowbellModerator client. - */ - public CowbellModeratorImpl() { - this("https://localhost"); - } - - /** - * Initializes an instance of CowbellModerator client. - * - * @param baseUrl the base URL of the host - */ - public CowbellModeratorImpl(String baseUrl) { - super(baseUrl); - initialize(); - } - - /** - * Initializes an instance of CowbellModerator client. - * - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public CowbellModeratorImpl(OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - this("https://localhost", clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of CowbellModerator client. - * - * @param baseUrl the base URL of the host - * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations - * @param restBuilder the builder for building an Retrofit client, bundled with user configurations - */ - public CowbellModeratorImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { - super(baseUrl, clientBuilder, restBuilder); - initialize(); - } - - /** - * Initializes an instance of CowbellModerator client. - * - * @param restClient the REST client containing pre-configured settings - */ - public CowbellModeratorImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - private void initialize() { - this.images = new ImagesImpl(retrofit(), this); - this.texts = new TextsImpl(retrofit(), this); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/implementation/ImagesImpl.java b/Samples/test/stream-with-content-type/ClientJava/implementation/ImagesImpl.java index 21f651c0f..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/implementation/ImagesImpl.java +++ b/Samples/test/stream-with-content-type/ClientJava/implementation/ImagesImpl.java @@ -1,376 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype.implementation; - -import retrofit2.Retrofit; -import .Images; -import .models.ImageType; -import .models.ImageTypeRestricted; -import .models.ImageTypeRestrictedStrings; -import com.google.common.reflect.TypeToken; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.InputStream; -import java.io.IOException; -import okhttp3.MediaType; -import okhttp3.RequestBody; -import okhttp3.ResponseBody; -import retrofit2.http.Body; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.POST; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Images. - */ -public class ImagesImpl implements Images { - /** The Retrofit service to perform REST calls. */ - private ImagesService service; - /** The service client containing this operation class. */ - private CowbellModeratorImpl client; - - /** - * Initializes an instance of Images. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public ImagesImpl(Retrofit retrofit, CowbellModeratorImpl client) { - this.service = retrofit.create(ImagesService.class); - this.client = client; - } - - /** - * The interface defining all the services for Images to be - * used by Retrofit to perform actually REST calls. - */ - interface ImagesService { - @Headers({ "Content-Type: image/gif", "x-ms-logging-context: .Images a" }) - @POST("ProcessImage/FunctionA") - Observable> a(@Body RequestBody image, @Header("Content-Type") ImageType imageContentType); - - @Headers({ "Content-Type: image/gif", "x-ms-logging-context: .Images b" }) - @POST("ProcessImage/FunctionB") - Observable> b(@Body RequestBody image, @Header("Content-Type") ImageType imageContentType); - - @Headers({ "Content-Type: image/png", "x-ms-logging-context: .Images c" }) - @POST("ProcessImage/FunctionC") - Observable> c(@Body RequestBody image, @Header("Content-Type") ImageTypeRestricted imageContentType); - - @Headers({ "Content-Type: image/png", "x-ms-logging-context: .Images d" }) - @POST("ProcessImage/FunctionD") - Observable> d(@Body RequestBody image, @Header("Content-Type") ImageTypeRestrictedStrings imageContentType); - - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void a(byte[] image, ImageType imageContentType) { - aWithServiceResponseAsync(image, imageContentType).toBlocking().single().body(); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture aAsync(byte[] image, ImageType imageContentType, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(aWithServiceResponseAsync(image, imageContentType), serviceCallback); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable aAsync(byte[] image, ImageType imageContentType) { - return aWithServiceResponseAsync(image, imageContentType).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> aWithServiceResponseAsync(byte[] image, ImageType imageContentType) { - if (image == null) { - throw new IllegalArgumentException("Parameter image is required and cannot be null."); - } - if (imageContentType == null) { - throw new IllegalArgumentException("Parameter imageContentType is required and cannot be null."); - } - RequestBody imageConverted = RequestBody.create(MediaType.parse("image/gif"), image); - return service.a(imageConverted, imageContentType) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = aDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse aDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void b(byte[] image, ImageType imageContentType) { - bWithServiceResponseAsync(image, imageContentType).toBlocking().single().body(); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture bAsync(byte[] image, ImageType imageContentType, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(bWithServiceResponseAsync(image, imageContentType), serviceCallback); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable bAsync(byte[] image, ImageType imageContentType) { - return bWithServiceResponseAsync(image, imageContentType).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> bWithServiceResponseAsync(byte[] image, ImageType imageContentType) { - if (image == null) { - throw new IllegalArgumentException("Parameter image is required and cannot be null."); - } - if (imageContentType == null) { - throw new IllegalArgumentException("Parameter imageContentType is required and cannot be null."); - } - RequestBody imageConverted = RequestBody.create(MediaType.parse("image/gif"), image); - return service.b(imageConverted, imageContentType) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = bDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse bDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void c(byte[] image, ImageTypeRestricted imageContentType) { - cWithServiceResponseAsync(image, imageContentType).toBlocking().single().body(); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture cAsync(byte[] image, ImageTypeRestricted imageContentType, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(cWithServiceResponseAsync(image, imageContentType), serviceCallback); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable cAsync(byte[] image, ImageTypeRestricted imageContentType) { - return cWithServiceResponseAsync(image, imageContentType).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> cWithServiceResponseAsync(byte[] image, ImageTypeRestricted imageContentType) { - if (image == null) { - throw new IllegalArgumentException("Parameter image is required and cannot be null."); - } - if (imageContentType == null) { - throw new IllegalArgumentException("Parameter imageContentType is required and cannot be null."); - } - RequestBody imageConverted = RequestBody.create(MediaType.parse("image/png"), image); - return service.c(imageConverted, imageContentType) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = cDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse cDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void d(byte[] image, ImageTypeRestrictedStrings imageContentType) { - dWithServiceResponseAsync(image, imageContentType).toBlocking().single().body(); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture dAsync(byte[] image, ImageTypeRestrictedStrings imageContentType, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(dWithServiceResponseAsync(image, imageContentType), serviceCallback); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable dAsync(byte[] image, ImageTypeRestrictedStrings imageContentType) { - return dWithServiceResponseAsync(image, imageContentType).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * - * @param image An image stream. - * @param imageContentType The content type of the image. Possible values include: 'image/png', 'image/tiff' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> dWithServiceResponseAsync(byte[] image, ImageTypeRestrictedStrings imageContentType) { - if (image == null) { - throw new IllegalArgumentException("Parameter image is required and cannot be null."); - } - if (imageContentType == null) { - throw new IllegalArgumentException("Parameter imageContentType is required and cannot be null."); - } - RequestBody imageConverted = RequestBody.create(MediaType.parse("image/png"), image); - return service.d(imageConverted, imageContentType) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = dDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse dDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/implementation/TextsImpl.java b/Samples/test/stream-with-content-type/ClientJava/implementation/TextsImpl.java index 7f9f484a6..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/implementation/TextsImpl.java +++ b/Samples/test/stream-with-content-type/ClientJava/implementation/TextsImpl.java @@ -1,215 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype.implementation; - -import retrofit2.Retrofit; -import .Texts; -import com.google.common.reflect.TypeToken; -import com.microsoft.rest.RestException; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import java.io.InputStream; -import java.io.IOException; -import okhttp3.MediaType; -import okhttp3.RequestBody; -import okhttp3.ResponseBody; -import retrofit2.http.Body; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.POST; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Texts. - */ -public class TextsImpl implements Texts { - /** The Retrofit service to perform REST calls. */ - private TextsService service; - /** The service client containing this operation class. */ - private CowbellModeratorImpl client; - - /** - * Initializes an instance of Texts. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public TextsImpl(Retrofit retrofit, CowbellModeratorImpl client) { - this.service = retrofit.create(TextsService.class); - this.client = client; - } - - /** - * The interface defining all the services for Texts to be - * used by Retrofit to perform actually REST calls. - */ - interface TextsService { - @Headers({ "Content-Type: text/plain", "x-ms-logging-context: .Texts a" }) - @POST("ProcessImage/FunctionTA") - Observable> a(@Body RequestBody text, @Header("Content-Type") String contentType); - - @Headers({ "Content-Type: text/plain", "x-ms-logging-context: .Texts b" }) - @POST("ProcessImage/FunctionTB") - Observable> b(@Body RequestBody text, @Header("Content-Type") String contentType); - - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void a(byte[] text, String contentType) { - aWithServiceResponseAsync(text, contentType).toBlocking().single().body(); - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture aAsync(byte[] text, String contentType, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(aWithServiceResponseAsync(text, contentType), serviceCallback); - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable aAsync(byte[] text, String contentType) { - return aWithServiceResponseAsync(text, contentType).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> aWithServiceResponseAsync(byte[] text, String contentType) { - if (text == null) { - throw new IllegalArgumentException("Parameter text is required and cannot be null."); - } - if (contentType == null) { - throw new IllegalArgumentException("Parameter contentType is required and cannot be null."); - } - RequestBody textConverted = RequestBody.create(MediaType.parse("text/plain"), text); - return service.a(textConverted, contentType) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = aDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse aDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws RestException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void b(byte[] text, String contentType) { - bWithServiceResponseAsync(text, contentType).toBlocking().single().body(); - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture bAsync(byte[] text, String contentType, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(bWithServiceResponseAsync(text, contentType), serviceCallback); - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable bAsync(byte[] text, String contentType) { - return bWithServiceResponseAsync(text, contentType).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * - * @param text A text stream. - * @param contentType The content type of the image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> bWithServiceResponseAsync(byte[] text, String contentType) { - if (text == null) { - throw new IllegalArgumentException("Parameter text is required and cannot be null."); - } - if (contentType == null) { - throw new IllegalArgumentException("Parameter contentType is required and cannot be null."); - } - RequestBody textConverted = RequestBody.create(MediaType.parse("text/plain"), text); - return service.b(textConverted, contentType) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = bDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse bDelegate(Response response) throws RestException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .build(response); - } - -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/implementation/package-info.java b/Samples/test/stream-with-content-type/ClientJava/implementation/package-info.java index ca3443714..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/implementation/package-info.java +++ b/Samples/test/stream-with-content-type/ClientJava/implementation/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for CowbellModerator. - */ -package streamwithcontenttype.implementation; +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/models/ContentTypes.java b/Samples/test/stream-with-content-type/ClientJava/models/ContentTypes.java index 3bffdcf7c..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/models/ContentTypes.java +++ b/Samples/test/stream-with-content-type/ClientJava/models/ContentTypes.java @@ -1,42 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype.models; - -import java.util.Collection; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.microsoft.rest.ExpandableStringEnum; - -/** - * Defines values for ContentTypes. - */ -public final class ContentTypes extends ExpandableStringEnum { - /** Static value text/plain for ContentTypes. */ - public static final ContentTypes TEXTPLAIN = fromString("text/plain"); - - /** Static value text/json for ContentTypes. */ - public static final ContentTypes TEXTJSON = fromString("text/json"); - - /** Static value text/xml for ContentTypes. */ - public static final ContentTypes TEXTXML = fromString("text/xml"); - - /** - * Creates or finds a ContentTypes from its string representation. - * @param name a name to look for - * @return the corresponding ContentTypes - */ - @JsonCreator - public static ContentTypes fromString(String name) { - return fromString(name, ContentTypes.class); - } - - /** - * @return known ContentTypes values - */ - public static Collection values() { - return values(ContentTypes.class); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/models/ImageType.java b/Samples/test/stream-with-content-type/ClientJava/models/ImageType.java index 9a78da5e3..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/models/ImageType.java +++ b/Samples/test/stream-with-content-type/ClientJava/models/ImageType.java @@ -1,60 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ImageType. - */ -public enum ImageType { - /** Enum value image/gif. */ - IMAGEGIF("image/gif"), - - /** Enum value image/jpeg. */ - IMAGEJPEG("image/jpeg"), - - /** Enum value image/png. */ - IMAGEPNG("image/png"), - - /** Enum value image/bmp. */ - IMAGEBMP("image/bmp"), - - /** Enum value image/tiff. */ - IMAGETIFF("image/tiff"); - - /** The actual serialized value for a ImageType instance. */ - private String value; - - ImageType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ImageType instance. - * - * @param value the serialized value to parse. - * @return the parsed ImageType object, or null if unable to parse. - */ - @JsonCreator - public static ImageType fromString(String value) { - ImageType[] items = ImageType.values(); - for (ImageType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestricted.java b/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestricted.java index e106ecca8..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestricted.java +++ b/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestricted.java @@ -1,51 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ImageTypeRestricted. - */ -public enum ImageTypeRestricted { - /** Enum value image/png. */ - IMAGEPNG("image/png"), - - /** Enum value image/tiff. */ - IMAGETIFF("image/tiff"); - - /** The actual serialized value for a ImageTypeRestricted instance. */ - private String value; - - ImageTypeRestricted(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ImageTypeRestricted instance. - * - * @param value the serialized value to parse. - * @return the parsed ImageTypeRestricted object, or null if unable to parse. - */ - @JsonCreator - public static ImageTypeRestricted fromString(String value) { - ImageTypeRestricted[] items = ImageTypeRestricted.values(); - for (ImageTypeRestricted item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestrictedStrings.java b/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestrictedStrings.java index 35c7aaf83..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestrictedStrings.java +++ b/Samples/test/stream-with-content-type/ClientJava/models/ImageTypeRestrictedStrings.java @@ -1,39 +1 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package streamwithcontenttype.models; - -import java.util.Collection; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.microsoft.rest.ExpandableStringEnum; - -/** - * Defines values for ImageTypeRestrictedStrings. - */ -public final class ImageTypeRestrictedStrings extends ExpandableStringEnum { - /** Static value image/png for ImageTypeRestrictedStrings. */ - public static final ImageTypeRestrictedStrings IMAGEPNG = fromString("image/png"); - - /** Static value image/tiff for ImageTypeRestrictedStrings. */ - public static final ImageTypeRestrictedStrings IMAGETIFF = fromString("image/tiff"); - - /** - * Creates or finds a ImageTypeRestrictedStrings from its string representation. - * @param name a name to look for - * @return the corresponding ImageTypeRestrictedStrings - */ - @JsonCreator - public static ImageTypeRestrictedStrings fromString(String name) { - return fromString(name, ImageTypeRestrictedStrings.class); - } - - /** - * @return known ImageTypeRestrictedStrings values - */ - public static Collection values() { - return values(ImageTypeRestrictedStrings.class); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/models/package-info.java b/Samples/test/stream-with-content-type/ClientJava/models/package-info.java index 70f300d95..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/models/package-info.java +++ b/Samples/test/stream-with-content-type/ClientJava/models/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the models classes for CowbellModerator. - */ -package streamwithcontenttype.models; +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientJava/package-info.java b/Samples/test/stream-with-content-type/ClientJava/package-info.java index 99c851750..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientJava/package-info.java +++ b/Samples/test/stream-with-content-type/ClientJava/package-info.java @@ -1,8 +1 @@ -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the classes for CowbellModerator. - */ -package streamwithcontenttype; +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientNode/cowbellModerator.js b/Samples/test/stream-with-content-type/ClientNode/cowbellModerator.js index a40586674..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientNode/cowbellModerator.js +++ b/Samples/test/stream-with-content-type/ClientNode/cowbellModerator.js @@ -1,50 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -const msRest = require('ms-rest'); -const ServiceClient = msRest.ServiceClient; - -const operations = require('./operations'); - - -/** Class representing a CowbellModerator. */ -class CowbellModerator extends ServiceClient { - /** - * Create a CowbellModerator. - * @param {string} [baseUri] - The base URI of the service. - * @param {object} [options] - The parameter options - * @param {Array} [options.filters] - Filters to be added to the request pipeline - * @param {object} [options.requestOptions] - Options for the underlying request object - * {@link https://github.com/request/request#requestoptions-callback Options doc} - * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy - */ - constructor(baseUri, options) { - - if (!options) options = {}; - - super(null, options); - - this.baseUri = baseUri; - if (!this.baseUri) { - this.baseUri = 'https://localhost'; - } - - let packageInfo = this.getPackageJsonInfo(__dirname); - this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); - this.image = new operations.Image(this); - this.text = new operations.Text(this); - msRest.addSerializationMixin(this); - } - -} - -module.exports = CowbellModerator; +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientNode/operations/image.js b/Samples/test/stream-with-content-type/ClientNode/operations/image.js index a744a0c2d..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientNode/operations/image.js +++ b/Samples/test/stream-with-content-type/ClientNode/operations/image.js @@ -1,801 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const msRest = require('ms-rest'); -const WebResource = msRest.WebResource; - -/** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - * 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _a(image, imageContentType, 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 (image === null || image === undefined) { - throw new Error('image cannot be null or undefined and it must be of type object.'); - } - if (imageContentType) { - let allowedValues = [ 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' ]; - if (!allowedValues.some( function(item) { return item === imageContentType; })) { - throw new Error(imageContentType + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('imageContentType cannot be null or undefined.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ProcessImage/FunctionA'; - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'image/gif'; - if (imageContentType !== undefined && imageContentType !== null) { - httpRequest.headers['Content-Type'] = imageContentType; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = image; - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - * 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _b(image, imageContentType, 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 (image === null || image === undefined) { - throw new Error('image cannot be null or undefined and it must be of type object.'); - } - if (imageContentType) { - let allowedValues = [ 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tiff' ]; - if (!allowedValues.some( function(item) { return item === imageContentType; })) { - throw new Error(imageContentType + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('imageContentType cannot be null or undefined.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ProcessImage/FunctionB'; - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'image/gif'; - if (imageContentType !== undefined && imageContentType !== null) { - httpRequest.headers['Content-Type'] = imageContentType; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = image; - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/png', 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _c(image, imageContentType, 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 (image === null || image === undefined) { - throw new Error('image cannot be null or undefined and it must be of type object.'); - } - if (imageContentType) { - let allowedValues = [ 'image/png', 'image/tiff' ]; - if (!allowedValues.some( function(item) { return item === imageContentType; })) { - throw new Error(imageContentType + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('imageContentType cannot be null or undefined.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ProcessImage/FunctionC'; - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'image/png'; - if (imageContentType !== undefined && imageContentType !== null) { - httpRequest.headers['Content-Type'] = imageContentType; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = image; - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/png', 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _d(image, imageContentType, 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 (image === null || image === undefined) { - throw new Error('image cannot be null or undefined and it must be of type object.'); - } - if (imageContentType === null || imageContentType === undefined || typeof imageContentType.valueOf() !== 'string') { - throw new Error('imageContentType cannot be null or undefined and it must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ProcessImage/FunctionD'; - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'image/png'; - if (imageContentType !== undefined && imageContentType !== null) { - httpRequest.headers['Content-Type'] = imageContentType; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = image; - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a Image. */ -class Image { - /** - * Create a Image. - * @param {CowbellModerator} client Reference to the service client. - */ - constructor(client) { - this.client = client; - this._a = _a; - this._b = _b; - this._c = _c; - this._d = _d; - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - * 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - aWithHttpOperationResponse(image, imageContentType, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._a(image, imageContentType, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - * 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - a(image, imageContentType, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._a(image, imageContentType, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._a(image, imageContentType, options, optionalCallback); - } - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - * 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - bWithHttpOperationResponse(image, imageContentType, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._b(image, imageContentType, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - * 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - b(image, imageContentType, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._b(image, imageContentType, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._b(image, imageContentType, options, optionalCallback); - } - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/png', 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - cWithHttpOperationResponse(image, imageContentType, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._c(image, imageContentType, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/png', 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - c(image, imageContentType, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._c(image, imageContentType, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._c(image, imageContentType, options, optionalCallback); - } - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/png', 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - dWithHttpOperationResponse(image, imageContentType, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._d(image, imageContentType, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @param {object} image An image stream. - * - * @param {string} imageContentType The content type of the image. Possible - * values include: 'image/png', 'image/tiff' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - d(image, imageContentType, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._d(image, imageContentType, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._d(image, imageContentType, options, optionalCallback); - } - } - -} - -module.exports = Image; +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientNode/operations/index.js b/Samples/test/stream-with-content-type/ClientNode/operations/index.js index 5810ae39f..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientNode/operations/index.js +++ b/Samples/test/stream-with-content-type/ClientNode/operations/index.js @@ -1,14 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -/* jshint latedef:false */ -/* jshint forin:false */ -/* jshint noempty:false */ - -'use strict'; - -exports.Image = require('./image'); -exports.Text = require('./text'); +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientNode/operations/text.js b/Samples/test/stream-with-content-type/ClientNode/operations/text.js index fcc84ee5c..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientNode/operations/text.js +++ b/Samples/test/stream-with-content-type/ClientNode/operations/text.js @@ -1,396 +1 @@ -/* - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -'use strict'; - -const msRest = require('ms-rest'); -const WebResource = msRest.WebResource; - -/** - * @param {object} text A text stream. - * - * @param {string} contentType The content type of the image. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _a(text, contentType, 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 (text === null || text === undefined) { - throw new Error('text cannot be null or undefined and it must be of type object.'); - } - if (contentType === null || contentType === undefined || typeof contentType.valueOf() !== 'string') { - throw new Error('contentType cannot be null or undefined and it must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ProcessImage/FunctionTA'; - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'text/plain'; - if (contentType !== undefined && contentType !== null) { - httpRequest.headers['Content-Type'] = contentType; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = text; - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @param {object} text A text stream. - * - * @param {string} contentType The content type of the image. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _b(text, contentType, 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 (text === null || text === undefined) { - throw new Error('text cannot be null or undefined and it must be of type object.'); - } - if (contentType === null || contentType === undefined || typeof contentType.valueOf() !== 'string') { - throw new Error('contentType cannot be null or undefined and it must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ProcessImage/FunctionTB'; - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'text/plain'; - if (contentType !== undefined && contentType !== null) { - httpRequest.headers['Content-Type'] = contentType; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - // Serialize Request - let requestContent = text; - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a Text. */ -class Text { - /** - * Create a Text. - * @param {CowbellModerator} client Reference to the service client. - */ - constructor(client) { - this.client = client; - this._a = _a; - this._b = _b; - } - - /** - * @param {object} text A text stream. - * - * @param {string} contentType The content type of the image. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - aWithHttpOperationResponse(text, contentType, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._a(text, contentType, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @param {object} text A text stream. - * - * @param {string} contentType The content type of the image. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - a(text, contentType, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._a(text, contentType, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._a(text, contentType, options, optionalCallback); - } - } - - /** - * @param {object} text A text stream. - * - * @param {string} contentType The content type of the image. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - bWithHttpOperationResponse(text, contentType, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._b(text, contentType, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @param {object} text A text stream. - * - * @param {string} contentType The content type of the image. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - b(text, contentType, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._b(text, contentType, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._b(text, contentType, options, optionalCallback); - } - } - -} - -module.exports = Text; +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/__init__.py b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/__init__.py index 4f39eafcf..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/__init__.py +++ b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/__init__.py @@ -1,14 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .cowbell_moderator import CowbellModerator -from .version import VERSION - -__all__ = ['CowbellModerator'] - -__version__ = VERSION - +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/cowbell_moderator.py b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/cowbell_moderator.py index 1e568b600..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/cowbell_moderator.py +++ b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/cowbell_moderator.py @@ -1,63 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.service_client import ServiceClient -from msrest import Configuration, Serializer, Deserializer -from .version import VERSION -from msrest.exceptions import HttpOperationError -from .operations.image_operations import ImageOperations -from .operations.text_operations import TextOperations - - -class CowbellModeratorConfiguration(Configuration): - """Configuration for CowbellModerator - Note that all parameters used to create this instance are saved as instance - attributes. - - :param str base_url: Service URL - """ - - def __init__( - self, base_url=None): - - if not base_url: - base_url = 'https://localhost' - - super(CowbellModeratorConfiguration, self).__init__(base_url) - - self.add_user_agent('cowbellmoderator/{}'.format(VERSION)) - - -class CowbellModerator(object): - """CowbellModerator - - :ivar config: Configuration for client. - :vartype config: CowbellModeratorConfiguration - - :ivar image: Image operations - :vartype image: streamwithcontenttype.operations.ImageOperations - :ivar text: Text operations - :vartype text: streamwithcontenttype.operations.TextOperations - - :param str base_url: Service URL - """ - - def __init__( - self, base_url=None): - - self.config = CowbellModeratorConfiguration(base_url) - self._client = ServiceClient(None, self.config) - - client_models = {} - self.api_version = '1.0' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.image = ImageOperations( - self._client, self.config, self._serialize, self._deserialize) - self.text = TextOperations( - self._client, self.config, self._serialize, self._deserialize) +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/models/cowbell_moderator_enums.py b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/models/cowbell_moderator_enums.py index 774b0502e..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/models/cowbell_moderator_enums.py +++ b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/models/cowbell_moderator_enums.py @@ -1,36 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum - - -class ImageType(Enum): - - imagegif = "image/gif" - imagejpeg = "image/jpeg" - imagepng = "image/png" - imagebmp = "image/bmp" - imagetiff = "image/tiff" - - -class ImageTypeRestricted(Enum): - - imagepng = "image/png" - imagetiff = "image/tiff" - - -class ImageTypeRestrictedStrings(Enum): - - imagepng = "image/png" - imagetiff = "image/tiff" - - -class ContentTypes(Enum): - - textplain = "text/plain" - textjson = "text/json" - textxml = "text/xml" +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/__init__.py b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/__init__.py index 6c2dc3500..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/__init__.py +++ b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/__init__.py @@ -1,14 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .image_operations import ImageOperations -from .text_operations import TextOperations - -__all__ = [ - 'ImageOperations', - 'TextOperations', -] +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/image_operations.py b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/image_operations.py index b2f60c488..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/image_operations.py +++ b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/image_operations.py @@ -1,253 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.pipeline import ClientRawResponse -from msrest.exceptions import HttpOperationError - - -class ImageOperations(object): - """ImageOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - - self.config = config - - def a( - self, image, image_content_type, custom_headers=None, raw=False, callback=None, **operation_config): - """ - - :param image: An image stream. - :type image: Generator - :param image_content_type: The content type of the image. Possible - values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - 'image/tiff' - :type image_content_type: str or :class:`ImageType - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param callback: When specified, will be called with each chunk of - data that is streamed. The callback should take two arguments, the - bytes of the current chunk of data and the response object. If the - data is uploading, response will be None. - :type callback: Callable[Bytes, response=None] - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or - :class:`ClientRawResponse` if - raw=true - :rtype: None or - :class:`ClientRawResponse` - :raises: - :class:`HttpOperationError` - """ - # Construct URL - url = '/ProcessImage/FunctionA' - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'image/gif' - if custom_headers: - header_parameters.update(custom_headers) - header_parameters['Content-Type'] = self._serialize.header("image_content_type", image_content_type, 'ImageType') - - # Construct body - body_content = self._client.stream_upload(image, callback) - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def b( - self, image, image_content_type, custom_headers=None, raw=False, callback=None, **operation_config): - """ - - :param image: An image stream. - :type image: Generator - :param image_content_type: The content type of the image. Possible - values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - 'image/tiff' - :type image_content_type: str or :class:`ImageType - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param callback: When specified, will be called with each chunk of - data that is streamed. The callback should take two arguments, the - bytes of the current chunk of data and the response object. If the - data is uploading, response will be None. - :type callback: Callable[Bytes, response=None] - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or - :class:`ClientRawResponse` if - raw=true - :rtype: None or - :class:`ClientRawResponse` - :raises: - :class:`HttpOperationError` - """ - # Construct URL - url = '/ProcessImage/FunctionB' - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'image/gif' - if custom_headers: - header_parameters.update(custom_headers) - header_parameters['Content-Type'] = self._serialize.header("image_content_type", image_content_type, 'ImageType') - - # Construct body - body_content = self._client.stream_upload(image, callback) - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def c( - self, image, image_content_type, custom_headers=None, raw=False, callback=None, **operation_config): - """ - - :param image: An image stream. - :type image: Generator - :param image_content_type: The content type of the image. Possible - values include: 'image/png', 'image/tiff' - :type image_content_type: str or :class:`ImageTypeRestricted - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param callback: When specified, will be called with each chunk of - data that is streamed. The callback should take two arguments, the - bytes of the current chunk of data and the response object. If the - data is uploading, response will be None. - :type callback: Callable[Bytes, response=None] - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or - :class:`ClientRawResponse` if - raw=true - :rtype: None or - :class:`ClientRawResponse` - :raises: - :class:`HttpOperationError` - """ - # Construct URL - url = '/ProcessImage/FunctionC' - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'image/png' - if custom_headers: - header_parameters.update(custom_headers) - header_parameters['Content-Type'] = self._serialize.header("image_content_type", image_content_type, 'ImageTypeRestricted') - - # Construct body - body_content = self._client.stream_upload(image, callback) - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def d( - self, image, image_content_type, custom_headers=None, raw=False, callback=None, **operation_config): - """ - - :param image: An image stream. - :type image: Generator - :param image_content_type: The content type of the image. Possible - values include: 'image/png', 'image/tiff' - :type image_content_type: str or :class:`ImageTypeRestrictedStrings - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param callback: When specified, will be called with each chunk of - data that is streamed. The callback should take two arguments, the - bytes of the current chunk of data and the response object. If the - data is uploading, response will be None. - :type callback: Callable[Bytes, response=None] - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or - :class:`ClientRawResponse` if - raw=true - :rtype: None or - :class:`ClientRawResponse` - :raises: - :class:`HttpOperationError` - """ - # Construct URL - url = '/ProcessImage/FunctionD' - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'image/png' - if custom_headers: - header_parameters.update(custom_headers) - header_parameters['Content-Type'] = self._serialize.header("image_content_type", image_content_type, 'str') - - # Construct body - body_content = self._client.stream_upload(image, callback) - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/text_operations.py b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/text_operations.py index 555670e85..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/text_operations.py +++ b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/operations/text_operations.py @@ -1,135 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.pipeline import ClientRawResponse -from msrest.exceptions import HttpOperationError - - -class TextOperations(object): - """TextOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - - self.config = config - - def a( - self, text, content_type, custom_headers=None, raw=False, callback=None, **operation_config): - """ - - :param text: A text stream. - :type text: Generator - :param content_type: The content type of the image. - :type content_type: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param callback: When specified, will be called with each chunk of - data that is streamed. The callback should take two arguments, the - bytes of the current chunk of data and the response object. If the - data is uploading, response will be None. - :type callback: Callable[Bytes, response=None] - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or - :class:`ClientRawResponse` if - raw=true - :rtype: None or - :class:`ClientRawResponse` - :raises: - :class:`HttpOperationError` - """ - # Construct URL - url = '/ProcessImage/FunctionTA' - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'text/plain' - if custom_headers: - header_parameters.update(custom_headers) - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - # Construct body - body_content = self._client.stream_upload(text, callback) - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def b( - self, text, content_type, custom_headers=None, raw=False, callback=None, **operation_config): - """ - - :param text: A text stream. - :type text: Generator - :param content_type: The content type of the image. - :type content_type: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param callback: When specified, will be called with each chunk of - data that is streamed. The callback should take two arguments, the - bytes of the current chunk of data and the response object. If the - data is uploading, response will be None. - :type callback: Callable[Bytes, response=None] - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or - :class:`ClientRawResponse` if - raw=true - :rtype: None or - :class:`ClientRawResponse` - :raises: - :class:`HttpOperationError` - """ - # Construct URL - url = '/ProcessImage/FunctionTB' - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'text/plain' - if custom_headers: - header_parameters.update(custom_headers) - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - # Construct body - body_content = self._client.stream_upload(text, callback) - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/version.py b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/version.py index 096aeed2c..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/version.py +++ b/Samples/test/stream-with-content-type/ClientPython/cowbell_moderator/version.py @@ -1,9 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "1.0" - +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientPython/setup.py b/Samples/test/stream-with-content-type/ClientPython/setup.py index 40e3eefab..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientPython/setup.py +++ b/Samples/test/stream-with-content-type/ClientPython/setup.py @@ -1,35 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# coding: utf-8 - -from setuptools import setup, find_packages - -NAME = "cowbellmoderator" -VERSION = "1.0" - -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools - -REQUIRES = ["msrest>=0.2.0"] - -setup( - name=NAME, - version=VERSION, - description="CowbellModerator", - author_email="", - url="", - keywords=["Swagger", "CowbellModerator"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - """ -) +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type.rb index 6f1fb76da..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type.rb @@ -1,32 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -require 'uri' -require 'cgi' -require 'date' -require 'json' -require 'base64' -require 'erb' -require 'securerandom' -require 'time' -require 'timeliness' -require 'faraday' -require 'faraday-cookie_jar' -require 'concurrent' -require 'ms_rest' -require 'generated/stream_with_content_type/module_definition' - -module StreamWithContentType - autoload :Image, 'generated/stream_with_content_type/image.rb' - autoload :Text, 'generated/stream_with_content_type/text.rb' - autoload :CowbellModerator, 'generated/stream_with_content_type/cowbell_moderator.rb' - - module Models - autoload :ImageType, 'generated/stream_with_content_type/models/image_type.rb' - autoload :ImageTypeRestricted, 'generated/stream_with_content_type/models/image_type_restricted.rb' - autoload :ImageTypeRestrictedStrings, 'generated/stream_with_content_type/models/image_type_restricted_strings.rb' - autoload :ContentTypes, 'generated/stream_with_content_type/models/content_types.rb' - end -end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/cowbell_moderator.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/cowbell_moderator.rb index b36e8072f..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/cowbell_moderator.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/cowbell_moderator.rb @@ -1,107 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType - # - # A service client - single point of access to the REST API. - # - class CowbellModerator < MsRest::ServiceClient - include MsRest::Serialization - - # @return [String] the base URI of the service. - attr_accessor :base_url - - # @return [Image] image - attr_reader :image - - # @return [Text] text - attr_reader :text - - # - # Creates initializes a new instance of the CowbellModerator class. - # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. - # @param base_url [String] the base URI of the service. - # @param options [Array] filters to be applied to the HTTP requests. - # - def initialize(credentials = nil, base_url = nil, options = nil) - super(credentials, options) - @base_url = base_url || 'https://localhost' - - fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? - @credentials = credentials - - @image = Image.new(self) - @text = Text.new(self) - add_telemetry - end - - # - # Makes a request and returns the body of the response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Hash{String=>String}] containing the body of the response. - # Example: - # - # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}" - # path = "/path" - # options = { - # body: request_content, - # query_params: {'api-version' => '2016-02-01'} - # } - # result = @client.make_request(:put, path, options) - # - def make_request(method, path, options = {}) - result = make_request_with_http_info(method, path, options) - result.body unless result.nil? - end - - # - # Makes a request and returns the operation response. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [MsRest::HttpOperationResponse] Operation response containing the request, response and status. - # - def make_request_with_http_info(method, path, options = {}) - result = make_request_async(method, path, options).value! - result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body) - result - end - - # - # Makes a request asynchronously. - # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. - # @param path [String] the path, relative to {base_url}. - # @param options [Hash{String=>String}] specifying any request options like :body. - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def make_request_async(method, path, options = {}) - fail ArgumentError, 'method is nil' if method.nil? - fail ArgumentError, 'path is nil' if path.nil? - - request_url = options[:base_url] || @base_url - - request_headers = @request_headers - options.merge!({headers: request_headers.merge(options[:headers] || {})}) - options.merge!({credentials: @credentials}) unless @credentials.nil? - - super(request_url, method, path, options) - end - - - private - # - # Adds telemetry information. - # - def add_telemetry - sdk_information = 'stream_with_content_type' - if defined? StreamWithContentType::VERSION - sdk_information = "#{sdk_information}/#{StreamWithContentType::VERSION}" - end - add_user_agent_information(sdk_information) - end - end -end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/image.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/image.rb index 10044107a..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/image.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/image.rb @@ -1,378 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType - # - # Image - # - class Image - - # - # Creates and initializes a new instance of the Image class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [CowbellModerator] reference to the CowbellModerator - attr_reader :client - - # - # @param image An image stream. - # @param image_content_type [ImageType] The content type of the image. Possible - # values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - # 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def a(image, image_content_type, custom_headers = nil) - response = a_async(image, image_content_type, custom_headers).value! - nil - end - - # - # @param image An image stream. - # @param image_content_type [ImageType] The content type of the image. Possible - # values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - # 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def a_with_http_info(image, image_content_type, custom_headers = nil) - a_async(image, image_content_type, custom_headers).value! - end - - # - # @param image An image stream. - # @param image_content_type [ImageType] The content type of the image. Possible - # values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - # 'image/tiff' - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def a_async(image, image_content_type, custom_headers = nil) - fail ArgumentError, 'image is nil' if image.nil? - fail ArgumentError, 'image_content_type is nil' if image_content_type.nil? - - - request_headers = {} - - # Set Headers - fail RuntimeError, 'Header Content-Type is forbidden to change' - request_headers['Content-Type'] = image_content_type.to_s unless image_content_type.to_s.nil? - - request_headers['Content-Type'] = 'image/gif' - - # Serialize Request - request_mapper = { - required: true, - serialized_name: 'Image', - type: { - name: 'Stream' - } - } - request_content = @client.serialize(request_mapper, image) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'ProcessImage/FunctionA' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # @param image An image stream. - # @param image_content_type [ImageType] The content type of the image. Possible - # values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - # 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def b(image, image_content_type, custom_headers = nil) - response = b_async(image, image_content_type, custom_headers).value! - nil - end - - # - # @param image An image stream. - # @param image_content_type [ImageType] The content type of the image. Possible - # values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - # 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def b_with_http_info(image, image_content_type, custom_headers = nil) - b_async(image, image_content_type, custom_headers).value! - end - - # - # @param image An image stream. - # @param image_content_type [ImageType] The content type of the image. Possible - # values include: 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', - # 'image/tiff' - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def b_async(image, image_content_type, custom_headers = nil) - fail ArgumentError, 'image is nil' if image.nil? - fail ArgumentError, 'image_content_type is nil' if image_content_type.nil? - - - request_headers = {} - - # Set Headers - fail RuntimeError, 'Header Content-Type is forbidden to change' - request_headers['Content-Type'] = image_content_type.to_s unless image_content_type.to_s.nil? - - request_headers['Content-Type'] = 'image/gif' - - # Serialize Request - request_mapper = { - required: true, - serialized_name: 'Image', - type: { - name: 'Stream' - } - } - request_content = @client.serialize(request_mapper, image) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'ProcessImage/FunctionB' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # @param image An image stream. - # @param image_content_type [ImageTypeRestricted] The content type of the - # image. Possible values include: 'image/png', 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def c(image, image_content_type, custom_headers = nil) - response = c_async(image, image_content_type, custom_headers).value! - nil - end - - # - # @param image An image stream. - # @param image_content_type [ImageTypeRestricted] The content type of the - # image. Possible values include: 'image/png', 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def c_with_http_info(image, image_content_type, custom_headers = nil) - c_async(image, image_content_type, custom_headers).value! - end - - # - # @param image An image stream. - # @param image_content_type [ImageTypeRestricted] The content type of the - # image. Possible values include: 'image/png', 'image/tiff' - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def c_async(image, image_content_type, custom_headers = nil) - fail ArgumentError, 'image is nil' if image.nil? - fail ArgumentError, 'image_content_type is nil' if image_content_type.nil? - - - request_headers = {} - - # Set Headers - fail RuntimeError, 'Header Content-Type is forbidden to change' - request_headers['Content-Type'] = image_content_type.to_s unless image_content_type.to_s.nil? - - request_headers['Content-Type'] = 'image/png' - - # Serialize Request - request_mapper = { - required: true, - serialized_name: 'Image', - type: { - name: 'Stream' - } - } - request_content = @client.serialize(request_mapper, image) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'ProcessImage/FunctionC' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # @param image An image stream. - # @param image_content_type [ImageTypeRestrictedStrings] The content type of - # the image. Possible values include: 'image/png', 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def d(image, image_content_type, custom_headers = nil) - response = d_async(image, image_content_type, custom_headers).value! - nil - end - - # - # @param image An image stream. - # @param image_content_type [ImageTypeRestrictedStrings] The content type of - # the image. Possible values include: 'image/png', 'image/tiff' - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def d_with_http_info(image, image_content_type, custom_headers = nil) - d_async(image, image_content_type, custom_headers).value! - end - - # - # @param image An image stream. - # @param image_content_type [ImageTypeRestrictedStrings] The content type of - # the image. Possible values include: 'image/png', 'image/tiff' - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def d_async(image, image_content_type, custom_headers = nil) - fail ArgumentError, 'image is nil' if image.nil? - fail ArgumentError, 'image_content_type is nil' if image_content_type.nil? - - - request_headers = {} - - # Set Headers - fail RuntimeError, 'Header Content-Type is forbidden to change' - request_headers['Content-Type'] = image_content_type.to_s unless image_content_type.to_s.nil? - - request_headers['Content-Type'] = 'image/png' - - # Serialize Request - request_mapper = { - required: true, - serialized_name: 'Image', - type: { - name: 'Stream' - } - } - request_content = @client.serialize(request_mapper, image) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'ProcessImage/FunctionD' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/content_types.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/content_types.rb index cff2001f9..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/content_types.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/content_types.rb @@ -1,17 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType - module Models - # - # Defines values for ContentTypes - # - module ContentTypes - Textplain = "text/plain" - Textjson = "text/json" - Textxml = "text/xml" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type.rb index 25f4ac17d..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type.rb @@ -1,19 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType - module Models - # - # Defines values for ImageType - # - module ImageType - Imagegif = "image/gif" - Imagejpeg = "image/jpeg" - Imagepng = "image/png" - Imagebmp = "image/bmp" - Imagetiff = "image/tiff" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted.rb index 604d5fe6c..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted.rb @@ -1,16 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType - module Models - # - # Defines values for ImageTypeRestricted - # - module ImageTypeRestricted - Imagepng = "image/png" - Imagetiff = "image/tiff" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted_strings.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted_strings.rb index df2ca2145..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted_strings.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/models/image_type_restricted_strings.rb @@ -1,16 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType - module Models - # - # Defines values for ImageTypeRestrictedStrings - # - module ImageTypeRestrictedStrings - Imagepng = "image/png" - Imagetiff = "image/tiff" - end - end -end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/module_definition.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/module_definition.rb index 10525429f..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/module_definition.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/module_definition.rb @@ -1,6 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType end +SRC \ No newline at end of file diff --git a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/text.rb b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/text.rb index e9a6ebd1a..9d6cafc2c 100644 --- a/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/text.rb +++ b/Samples/test/stream-with-content-type/ClientRuby/generated/stream_with_content_type/text.rb @@ -1,192 +1 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module StreamWithContentType - # - # Text - # - class Text - - # - # Creates and initializes a new instance of the Text class. - # @param client service class for accessing basic functionality. - # - def initialize(client) - @client = client - end - - # @return [CowbellModerator] reference to the CowbellModerator - attr_reader :client - - # - # @param text A text stream. - # @param content_type [String] The content type of the image. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def a(text, content_type, custom_headers = nil) - response = a_async(text, content_type, custom_headers).value! - nil - end - - # - # @param text A text stream. - # @param content_type [String] The content type of the image. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def a_with_http_info(text, content_type, custom_headers = nil) - a_async(text, content_type, custom_headers).value! - end - - # - # @param text A text stream. - # @param content_type [String] The content type of the image. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def a_async(text, content_type, custom_headers = nil) - fail ArgumentError, 'text is nil' if text.nil? - fail ArgumentError, 'content_type is nil' if content_type.nil? - - - request_headers = {} - - # Set Headers - fail RuntimeError, 'Header Content-Type is forbidden to change' - request_headers['Content-Type'] = content_type unless content_type.nil? - - request_headers['Content-Type'] = 'text/plain' - - # Serialize Request - request_mapper = { - required: true, - serialized_name: 'Text', - type: { - name: 'Stream' - } - } - request_content = @client.serialize(request_mapper, text) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'ProcessImage/FunctionTA' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - # - # @param text A text stream. - # @param content_type [String] The content type of the image. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def b(text, content_type, custom_headers = nil) - response = b_async(text, content_type, custom_headers).value! - nil - end - - # - # @param text A text stream. - # @param content_type [String] The content type of the image. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRest::HttpOperationResponse] HTTP response information. - # - def b_with_http_info(text, content_type, custom_headers = nil) - b_async(text, content_type, custom_headers).value! - end - - # - # @param text A text stream. - # @param content_type [String] The content type of the image. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def b_async(text, content_type, custom_headers = nil) - fail ArgumentError, 'text is nil' if text.nil? - fail ArgumentError, 'content_type is nil' if content_type.nil? - - - request_headers = {} - - # Set Headers - fail RuntimeError, 'Header Content-Type is forbidden to change' - request_headers['Content-Type'] = content_type unless content_type.nil? - - request_headers['Content-Type'] = 'text/plain' - - # Serialize Request - request_mapper = { - required: true, - serialized_name: 'Text', - type: { - name: 'Stream' - } - } - request_content = @client.serialize(request_mapper, text) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'ProcessImage/FunctionTB' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRest::HttpOperationError.new(result.request, http_response, error_model) - end - - - result - end - - promise.execute - end - - end -end +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/Client/CowbellFactory.cs b/Samples/test/use-default-in-constructor/Client/CowbellFactory.cs index 0c0ae51af..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/Client/CowbellFactory.cs +++ b/Samples/test/use-default-in-constructor/Client/CowbellFactory.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ICowbellOperations. - /// - public virtual ICowbellOperations Cowbell { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Cowbell = new CowbellOperations(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/Client/CowbellOperations.cs b/Samples/test/use-default-in-constructor/Client/CowbellOperations.cs index b1eeba1e2..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/Client/CowbellOperations.cs +++ b/Samples/test/use-default-in-constructor/Client/CowbellOperations.cs @@ -1,170 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial class CowbellOperations : IServiceOperations, ICowbellOperations - { - /// - /// Initializes a new instance of the CowbellOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellOperations(CowbellFactory client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellFactory - /// - public CowbellFactory Client { get; private set; } - - /// - /// A good description. - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/Client/CowbellOperationsExtensions.cs b/Samples/test/use-default-in-constructor/Client/CowbellOperationsExtensions.cs index 1d55d3bcc..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/Client/CowbellOperationsExtensions.cs +++ b/Samples/test/use-default-in-constructor/Client/CowbellOperationsExtensions.cs @@ -1,48 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CowbellOperations. - /// - public static partial class CowbellOperationsExtensions - { - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - public static void Add(this ICowbellOperations operations, Cowbell body) - { - operations.AddAsync(body).GetAwaiter().GetResult(); - } - - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task AddAsync(this ICowbellOperations operations, Cowbell body, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/Client/ICowbellFactory.cs b/Samples/test/use-default-in-constructor/Client/ICowbellFactory.cs index d40d6bfe4..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/Client/ICowbellFactory.cs +++ b/Samples/test/use-default-in-constructor/Client/ICowbellFactory.cs @@ -1,39 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ICowbellOperations. - /// - ICowbellOperations Cowbell { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/Client/ICowbellOperations.cs b/Samples/test/use-default-in-constructor/Client/ICowbellOperations.cs index 54cebb0d5..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/Client/ICowbellOperations.cs +++ b/Samples/test/use-default-in-constructor/Client/ICowbellOperations.cs @@ -1,40 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial interface ICowbellOperations - { - /// - /// A good description. - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/Client/Models/Cowbell.cs b/Samples/test/use-default-in-constructor/Client/Models/Cowbell.cs index b011c2f21..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/Client/Models/Cowbell.cs +++ b/Samples/test/use-default-in-constructor/Client/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name, long? id = default(long?)) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/ClientFancy/CowbellFactory.cs b/Samples/test/use-default-in-constructor/ClientFancy/CowbellFactory.cs index 0c0ae51af..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/ClientFancy/CowbellFactory.cs +++ b/Samples/test/use-default-in-constructor/ClientFancy/CowbellFactory.cs @@ -1,152 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// This is a sample. - /// - public partial class CowbellFactory : ServiceClient, ICowbellFactory - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Gets the ICowbellOperations. - /// - public virtual ICowbellOperations Cowbell { get; private set; } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CowbellFactory(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CowbellFactory class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellFactory(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - Cowbell = new CowbellOperations(this); - BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new List - { - new Iso8601TimeSpanConverter() - } - }; - CustomInitialize(); - } - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperations.cs b/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperations.cs index b1eeba1e2..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperations.cs +++ b/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperations.cs @@ -1,170 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial class CowbellOperations : IServiceOperations, ICowbellOperations - { - /// - /// Initializes a new instance of the CowbellOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CowbellOperations(CowbellFactory client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CowbellFactory - /// - public CowbellFactory Client { get; private set; } - - /// - /// A good description. - /// - /// - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - if (body != null) - { - body.Validate(); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "cowbell").ToString(); - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperationsExtensions.cs b/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperationsExtensions.cs index 1d55d3bcc..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperationsExtensions.cs +++ b/Samples/test/use-default-in-constructor/ClientFancy/CowbellOperationsExtensions.cs @@ -1,48 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CowbellOperations. - /// - public static partial class CowbellOperationsExtensions - { - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - public static void Add(this ICowbellOperations operations, Cowbell body) - { - operations.AddAsync(body).GetAwaiter().GetResult(); - } - - /// - /// A good description. - /// - /// - /// The operations group for this extension method. - /// - /// - /// - /// - /// The cancellation token. - /// - public static async Task AddAsync(this ICowbellOperations operations, Cowbell body, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.AddWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/ClientFancy/ICowbellFactory.cs b/Samples/test/use-default-in-constructor/ClientFancy/ICowbellFactory.cs index d40d6bfe4..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/ClientFancy/ICowbellFactory.cs +++ b/Samples/test/use-default-in-constructor/ClientFancy/ICowbellFactory.cs @@ -1,39 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Models; - using Newtonsoft.Json; - - /// - /// This is a sample. - /// - public partial interface ICowbellFactory : System.IDisposable - { - /// - /// The base URI of the service. - /// - System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - JsonSerializerSettings SerializationSettings { get; } - - /// - /// Gets or sets json deserialization settings. - /// - JsonSerializerSettings DeserializationSettings { get; } - - - /// - /// Gets the ICowbellOperations. - /// - ICowbellOperations Cowbell { get; } - - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/ClientFancy/ICowbellOperations.cs b/Samples/test/use-default-in-constructor/ClientFancy/ICowbellOperations.cs index 54cebb0d5..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/ClientFancy/ICowbellOperations.cs +++ b/Samples/test/use-default-in-constructor/ClientFancy/ICowbellOperations.cs @@ -1,40 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CowbellOperations operations. - /// - public partial interface ICowbellOperations - { - /// - /// A good description. - /// - /// - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when a required parameter is null - /// - Task AddWithHttpMessagesAsync(Cowbell body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} +SRC \ No newline at end of file diff --git a/Samples/test/use-default-in-constructor/ClientFancy/Models/Cowbell.cs b/Samples/test/use-default-in-constructor/ClientFancy/Models/Cowbell.cs index f4171099b..9d6cafc2c 100644 --- a/Samples/test/use-default-in-constructor/ClientFancy/Models/Cowbell.cs +++ b/Samples/test/use-default-in-constructor/ClientFancy/Models/Cowbell.cs @@ -1,65 +1 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace PropertyDefaults.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A cowbell. - /// - public partial class Cowbell - { - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Cowbell class. - /// - public Cowbell(string name = "shiny", long? id = 42) - { - Id = id; - Name = name; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// - [JsonProperty(PropertyName = "id")] - public long? Id { get; set; } - - /// - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - } - } -} +SRC \ No newline at end of file diff --git a/src/autorest-core/lib/autorest-core.ts b/src/autorest-core/lib/autorest-core.ts index 2cd207174..8b3fa156f 100644 --- a/src/autorest-core/lib/autorest-core.ts +++ b/src/autorest-core/lib/autorest-core.ts @@ -212,18 +212,15 @@ export class AutoRest extends EventEmitter { view.messageEmitter.removeAllListeners(); return true; } catch (e) { + const message = { Channel: Channel.Debug, Text: `Process() Cancelled due to exception : ${e.message}` }; if (e instanceof Exception) { - // console.error(e); - this.Finished.Dispatch(false); - if (view) { - view.messageEmitter.removeAllListeners(); - } - return false; + // idea: don't throw exceptions, just visibly log them and return false + message.Channel = Channel.Fatal; + e = false; } + this.Message.Dispatch(message); - this.Message.Dispatch({ Channel: Channel.Debug, Text: `Process() Cancelled due to exception : ${e.message}` }); this.Finished.Dispatch(e); - if (view) { view.messageEmitter.removeAllListeners(); } diff --git a/src/autorest-core/package.json b/src/autorest-core/package.json index 7e9f6d359..d56faa798 100644 --- a/src/autorest-core/package.json +++ b/src/autorest-core/package.json @@ -20,7 +20,7 @@ "homepage": "https://github.com/Azure/autorest/readme.md", "main": "./dist/main.js", "scripts": { - "test": "./node_modules/.bin/mocha ./dist/test", + "test": "./node_modules/.bin/mocha ./dist/test --timeout 0", "prepare": "shx mkdir -p ./dist/ && cd ./static_modules && npm install", "prepublishonly": "gulp build" }, diff --git a/src/autorest-core/test/blaming.ts b/src/autorest-core/test/blaming.ts index b4176287e..d5dfb53ae 100644 --- a/src/autorest-core/test/blaming.ts +++ b/src/autorest-core/test/blaming.ts @@ -13,7 +13,7 @@ import { parse } from "../lib/ref/jsonpath"; @suite class Blaming { - @test @timeout(0) async "end to end blaming with literate swagger"() { + @test async "end to end blaming with literate swagger"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/literate-example/readme-composite.md")); // PumpMessagesToConsole(autoRest); @@ -69,7 +69,7 @@ import { parse } from "../lib/ref/jsonpath"; } } - @test @timeout(0) async "generate resolved swagger with source map"() { + @test async "generate resolved swagger with source map"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/small-input/")); autoRest.AddConfiguration({ "output-artifact": ["swagger-document", "swagger-document.map"] }); const files: Artifact[] = []; @@ -84,7 +84,7 @@ import { parse } from "../lib/ref/jsonpath"; assert.ok(sourceMapObj.mappings.split(";").length > 1000); } - @test @timeout(0) async "large swagger performance"() { + @test async "large swagger performance"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/large-input/")); autoRest.AddConfiguration({ "output-artifact": ["swagger-document", "swagger-document.map"] }); const messages: Message[] = []; diff --git a/src/autorest-core/test/cancellation.ts b/src/autorest-core/test/cancellation.ts index 76e34d0fb..41e1aecec 100644 --- a/src/autorest-core/test/cancellation.ts +++ b/src/autorest-core/test/cancellation.ts @@ -45,13 +45,13 @@ import { Message } from "../lib/message"; assert.ok(ms2 - ms1 < 500); } - @test @timeout(60000) async "immediate"() { await this.TestCancellationAfter(0); } - @test @timeout(60000) async "after 100ms"() { await this.TestCancellationAfter(100); } - @test @timeout(60000) async "after 1s"() { await this.TestCancellationAfter(1000); } - @test @timeout(60000) async "after 2s"() { await this.TestCancellationAfter(2000); } - @test @timeout(60000) async "after 3s"() { await this.TestCancellationAfter(3000); } - @test @timeout(60000) async "after 5s"() { await this.TestCancellationAfter(5000); } - @test @timeout(60000) async "after 8s"() { await this.TestCancellationAfter(8000); } - @test @timeout(60000) async "after 10s"() { await this.TestCancellationAfter(10000); } - @test @timeout(60000) async "after 15s"() { await this.TestCancellationAfter(15000); } + @test async "immediate"() { await this.TestCancellationAfter(0); } + @test async "after 100ms"() { await this.TestCancellationAfter(100); } + @test async "after 1s"() { await this.TestCancellationAfter(1000); } + @test async "after 2s"() { await this.TestCancellationAfter(2000); } + @test async "after 3s"() { await this.TestCancellationAfter(3000); } + @test async "after 5s"() { await this.TestCancellationAfter(5000); } + @test async "after 8s"() { await this.TestCancellationAfter(8000); } + @test async "after 10s"() { await this.TestCancellationAfter(10000); } + @test async "after 15s"() { await this.TestCancellationAfter(15000); } } \ No newline at end of file diff --git a/src/autorest-core/test/commonmark.ts b/src/autorest-core/test/commonmark.ts index e5e0e34d5..02cb01c7c 100644 --- a/src/autorest-core/test/commonmark.ts +++ b/src/autorest-core/test/commonmark.ts @@ -19,7 +19,7 @@ import { PlainTextVersion } from "../lib/pipeline/commonmark-documentation"; return new Parser().parse(rawCommonmark); } - @test @timeout(30000) async "PlainTextVersion"() { + @test async "PlainTextVersion"() { const compare = (raw: string, expected: string) => assert.strictEqual(PlainTextVersion(this.Parse(raw)), expected); @@ -33,7 +33,7 @@ import { PlainTextVersion } from "../lib/pipeline/commonmark-documentation"; compare("Even fancier html tags
and
stuff", "Even fancier html tags and stuff"); } - @test @timeout(60000) async "resolve markdown descriptions"() { + @test async "resolve markdown descriptions"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/literate-example/")); autoRest.AddConfiguration({ "output-artifact": "swagger-document" }); diff --git a/src/autorest-core/test/directive.ts b/src/autorest-core/test/directive.ts index d2c3ff67f..b720e5bb9 100644 --- a/src/autorest-core/test/directive.ts +++ b/src/autorest-core/test/directive.ts @@ -8,7 +8,7 @@ import { Message, Channel } from "../lib/message"; @suite class Directive { - @test @timeout(0) async "suppression"() { + @test async "suppression"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/literate-example/")); autoRest.Message.Subscribe((_, m) => m.Channel === Channel.Fatal ? console.error(m.Text) : ""); @@ -86,7 +86,7 @@ import { Message, Channel } from "../lib/message"; await pickyRun({ suppress: ["AvoidNestedProperties"], where: "$..properties.properties", from: "swagger.md" }); } - @test @skip @timeout(0) async "set descriptions on different levels"() { + @test @skip async "set descriptions on different levels"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/literate-example/")); const GenerateCodeModel = async (config: any) => { diff --git a/src/autorest-core/test/end-to-end.ts b/src/autorest-core/test/end-to-end.ts index dec3970c3..532878dd6 100644 --- a/src/autorest-core/test/end-to-end.ts +++ b/src/autorest-core/test/end-to-end.ts @@ -8,7 +8,7 @@ import { Message, Channel } from "../lib/message"; import { PumpMessagesToConsole } from './test-utility'; @suite class EndToEnd { - @test @timeout(120000) async "network full game"() { + @test async "network full game"() { const autoRest = new AutoRest(new RealFileSystem()); // PumpMessagesToConsole(autoRest); autoRest.AddConfiguration({ @@ -43,7 +43,7 @@ import { PumpMessagesToConsole } from './test-utility'; assert.strictEqual(success, true); } - @test @timeout(60000) async "other configuration scenario"() { + @test async "other configuration scenario"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/literate-example/readme-complicated.md")); // PumpMessagesToConsole(autoRest); @@ -53,7 +53,7 @@ import { PumpMessagesToConsole } from './test-utility'; } - @test @timeout(60000) async "complicated configuration scenario"() { + @test async "complicated configuration scenario"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/literate-example/readme-complicated.md")); // PumpMessagesToConsole(autoRest); autoRest.AddConfiguration({ @@ -77,7 +77,7 @@ import { PumpMessagesToConsole } from './test-utility'; // testing end-to-end for non-arm type validation rules. Since all validation rules are currently defaulted to // ARM, non-ARM documents should show 0 validation messages // TODO: fix this test when validation rules are properly categorized - @test @timeout(60000) async "non-arm type spec testing"() { + @test async "non-arm type spec testing"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/validation-options/readme.md")); autoRest.AddConfiguration({ "openapi-type": "default", @@ -93,7 +93,7 @@ import { PumpMessagesToConsole } from './test-utility'; // flag any fatal errors assert.equal(messages.filter(m => m.Channel === Channel.Fatal).length, 0); } - @test @timeout(60000) async "arm type spec testing"() { + @test async "arm type spec testing"() { const autoRest = new AutoRest(new RealFileSystem(), ResolveUri(CreateFolderUri(__dirname), "../../test/resources/validation-options/readme.md")); autoRest.AddConfiguration({ "openapi-type": "arm", diff --git a/src/autorest-core/test/plugin.ts b/src/autorest-core/test/plugin.ts index cb16e566c..f29f6f5e8 100644 --- a/src/autorest-core/test/plugin.ts +++ b/src/autorest-core/test/plugin.ts @@ -29,7 +29,7 @@ async function GetAutoRestDotNetPlugin(plugin: string): Promise