emit exceptions too, some dedupe, less strict diff (#2651)

* emit exceptions too

* timeout once and for all

* log exceptions visibly

* regen

* mute file outputs

* regen

* indent
This commit is contained in:
Johannes Bader 2017-10-11 12:52:15 -07:00 коммит произвёл Garrett Serack
Родитель 05fba30f07
Коммит 7121d7189c
911 изменённых файлов: 945 добавлений и 163162 удалений

Просмотреть файл

@ -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
)

Просмотреть файл

@ -1,406 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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;
/// <summary>
/// This is a sample server Petstore server. You can find out more about
/// Swagger at &lt;a
/// href="http://swagger.io"&gt;http://swagger.io&lt;/a&gt; or on
/// irc.freenode.net, #swagger. For this sample, you can use the api key
/// "special-key" to test the authorization filters
/// </summary>
public partial interface ISwaggerPetstore : System.IDisposable
{
/// <summary>
/// The base URI of the service.
/// </summary>
System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
JsonSerializerSettings SerializationSettings { get; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
JsonSerializerSettings DeserializationSettings { get; }
/// <summary>
/// Fake endpoint to test byte array in body parameter for adding a new
/// pet to the store
/// </summary>
/// <param name='body'>
/// Pet object in the form of byte array
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> AddPetUsingByteArrayWithHttpMessagesAsync(string body = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <remarks>
/// Adds a new pet to the store. You may receive an HTTP invalid input
/// if your pet is invalid.
/// </remarks>
/// <param name='body'>
/// Pet object that needs to be added to the store
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> AddPetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Update an existing pet
/// </summary>
/// <param name='body'>
/// Pet object that needs to be added to the store
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> UpdatePetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Finds Pets by status
/// </summary>
/// <remarks>
/// Multiple status values can be provided with comma seperated strings
/// </remarks>
/// <param name='status'>
/// Status values that need to be considered for filter
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<IList<Pet>>> FindPetsByStatusWithHttpMessagesAsync(IList<string> status = default(IList<string>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Finds Pets by tags
/// </summary>
/// <remarks>
/// Muliple tags can be provided with comma seperated strings. Use
/// tag1, tag2, tag3 for testing.
/// </remarks>
/// <param name='tags'>
/// Tags to filter by
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<IList<Pet>>> FindPetsByTagsWithHttpMessagesAsync(IList<string> tags = default(IList<string>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Fake endpoint to test byte array return by 'Find pet by ID'
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will
/// simulate API error conditions
/// </remarks>
/// <param name='petId'>
/// ID of pet that needs to be fetched
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<string>> FindPetsWithByteArrayWithHttpMessagesAsync(long petId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Find pet by ID
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will
/// simulate API error conditions
/// </remarks>
/// <param name='petId'>
/// ID of pet that needs to be fetched
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<Pet>> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <param name='petId'>
/// ID of pet that needs to be updated
/// </param>
/// <param name='name'>
/// Updated name of the pet
/// </param>
/// <param name='status'>
/// Updated status of the pet
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> UpdatePetWithFormWithHttpMessagesAsync(string petId, string name = default(string), string status = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name='petId'>
/// Pet id to delete
/// </param>
/// <param name='apiKey'>
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> DeletePetWithHttpMessagesAsync(long petId, string apiKey = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// uploads an image
/// </summary>
/// <param name='petId'>
/// ID of pet to update
/// </param>
/// <param name='additionalMetadata'>
/// Additional data to pass to server
/// </param>
/// <param name='file'>
/// file to upload
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> UploadFileWithHttpMessagesAsync(long petId, string additionalMetadata = default(string), Stream file = default(Stream), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Returns pet inventories by status
/// </summary>
/// <remarks>
/// Returns a map of status codes to quantities
/// </remarks>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<IDictionary<string, int?>>> GetInventoryWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Place an order for a pet
/// </summary>
/// <param name='body'>
/// order placed for purchasing the pet
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<Order>> PlaceOrderWithHttpMessagesAsync(Order body = default(Order), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Find purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt;= 5 or &gt; 10.
/// Other values will generated exceptions
/// </remarks>
/// <param name='orderId'>
/// ID of pet that needs to be fetched
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<Order>> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Delete purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt; 1000. Anything
/// above 1000 or nonintegers will generate API errors
/// </remarks>
/// <param name='orderId'>
/// ID of the order that needs to be deleted
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Create user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='body'>
/// Created user object
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> CreateUserWithHttpMessagesAsync(User body = default(User), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name='body'>
/// List of user object
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> CreateUsersWithArrayInputWithHttpMessagesAsync(IList<User> body = default(IList<User>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name='body'>
/// List of user object
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> CreateUsersWithListInputWithHttpMessagesAsync(IList<User> body = default(IList<User>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name='username'>
/// The user name for login
/// </param>
/// <param name='password'>
/// The password for login in clear text
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<string>> LoginUserWithHttpMessagesAsync(string username = default(string), string password = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> LogoutUserWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Get user by user name
/// </summary>
/// <param name='username'>
/// The name that needs to be fetched. Use user1 for testing.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<User>> GetUserByNameWithHttpMessagesAsync(string username, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Updated user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='username'>
/// name that need to be deleted
/// </param>
/// <param name='body'>
/// Updated user object
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> UpdateUserWithHttpMessagesAsync(string username, User body = default(User), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Delete user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='username'>
/// The name that needs to be deleted
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> DeleteUserWithHttpMessagesAsync(string username, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,90 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Petstore.Models
{
using Newtonsoft.Json;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
public partial class Category
{
/// <summary>
/// Initializes a new instance of the Category class.
/// </summary>
public Category()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Category class.
/// </summary>
public Category(long? id = default(long?), string name = default(string))
{
Id = id;
Name = name;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "id")]
public long? Id { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// Serializes the object to an XML node
/// </summary>
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;
}
/// <summary>
/// Deserializes an XML node to an instance of Category
/// </summary>
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

Просмотреть файл

@ -1,158 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Petstore.Models
{
using Newtonsoft.Json;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
public partial class Order
{
/// <summary>
/// Initializes a new instance of the Order class.
/// </summary>
public Order()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Order class.
/// </summary>
/// <param name="status">Order Status. Possible values include:
/// 'placed', 'approved', 'delivered'</param>
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();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "id")]
public long? Id { get; private set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "petId")]
public long? PetId { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "quantity")]
public int? Quantity { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "shipDate")]
public System.DateTime? ShipDate { get; set; }
/// <summary>
/// Gets or sets order Status. Possible values include: 'placed',
/// 'approved', 'delivered'
/// </summary>
[JsonProperty(PropertyName = "status")]
public string Status { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "complete")]
public bool? Complete { get; set; }
/// <summary>
/// Serializes the object to an XML node
/// </summary>
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;
}
/// <summary>
/// Deserializes an XML node to an instance of Order
/// </summary>
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

Просмотреть файл

@ -1,197 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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;
/// <summary>
/// A pet
/// </summary>
/// <remarks>
/// A group of properties representing a pet.
/// </remarks>
public partial class Pet
{
/// <summary>
/// Initializes a new instance of the Pet class.
/// </summary>
public Pet()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Pet class.
/// </summary>
/// <param name="id">The id of the pet.</param>
/// <param name="status">pet status in the store. Possible values
/// include: 'available', 'pending', 'sold'</param>
public Pet(string name, IList<string> photoUrls, long? id = default(long?), Category category = default(Category), IList<Tag> tags = default(IList<Tag>), string status = default(string))
{
Id = id;
Category = category;
Name = name;
PhotoUrls = photoUrls;
Tags = tags;
Status = status;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets the id of the pet.
/// </summary>
/// <remarks>
/// A more detailed description of the id of the pet.
/// </remarks>
[JsonProperty(PropertyName = "id")]
public long? Id { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "category")]
public Category Category { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "photoUrls")]
public IList<string> PhotoUrls { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "tags")]
public IList<Tag> Tags { get; set; }
/// <summary>
/// Gets or sets pet status in the store. Possible values include:
/// 'available', 'pending', 'sold'
/// </summary>
[JsonProperty(PropertyName = "status")]
public string Status { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Name == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Name");
}
if (PhotoUrls == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls");
}
}
/// <summary>
/// Serializes the object to an XML node
/// </summary>
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;
}
/// <summary>
/// Deserializes an XML node to an instance of Pet
/// </summary>
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<string> resultPhotoUrls;
if (deserializePhotoUrls(payload, "photoUrl", out resultPhotoUrls))
{
result.PhotoUrls = resultPhotoUrls;
}
var deserializeTags = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Tag.XmlDeserialize(e)), "tag");
IList<Tag> 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

Просмотреть файл

@ -1,90 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Petstore.Models
{
using Newtonsoft.Json;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
public partial class Tag
{
/// <summary>
/// Initializes a new instance of the Tag class.
/// </summary>
public Tag()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Tag class.
/// </summary>
public Tag(long? id = default(long?), string name = default(string))
{
Id = id;
Name = name;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "id")]
public long? Id { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// Serializes the object to an XML node
/// </summary>
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;
}
/// <summary>
/// Deserializes an XML node to an instance of Tag
/// </summary>
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

Просмотреть файл

@ -1,188 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Petstore.Models
{
using Newtonsoft.Json;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
public partial class User
{
/// <summary>
/// Initializes a new instance of the User class.
/// </summary>
public User()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the User class.
/// </summary>
/// <param name="userStatus">User Status</param>
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();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "id")]
public long? Id { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "username")]
public string Username { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "firstName")]
public string FirstName { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "lastName")]
public string LastName { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "email")]
public string Email { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "password")]
public string Password { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "phone")]
public string Phone { get; set; }
/// <summary>
/// Gets or sets user Status
/// </summary>
[JsonProperty(PropertyName = "userStatus")]
public int? UserStatus { get; set; }
/// <summary>
/// Serializes the object to an XML node
/// </summary>
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;
}
/// <summary>
/// Deserializes an XML node to an instance of User
/// </summary>
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

Просмотреть файл

@ -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<T>( XElement root, out T result );
internal delegate bool XmlDeserializer<T>( XElement parent, string propertyName, out T result );
internal static XmlRootDeserializer<T> Root<T>( XmlDeserializer<T> deserializer ) =>
(XElement root, out T result) => deserializer(new XElement("artificialRoot", root), root.Name.LocalName, out result);
private static XmlDeserializer<T> Unroot<T>( XmlRootDeserializer<T> 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<T> ToRootDeserializer<T>( System.Func<XElement, T> unsafeDeserializer )
=> (XElement root, out T result) => {
try
{
result = unsafeDeserializer(root);
return true;
}
catch
{
result = default(T);
return false;
}};
internal static XmlDeserializer<T> ToDeserializer<T>( System.Func<XElement, T> unsafeDeserializer )
=> Unroot(ToRootDeserializer(unsafeDeserializer));
internal static XmlDeserializer<IList<T>> CreateListXmlDeserializer<T>( XmlDeserializer<T> 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<T> 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<T> result) => {
result = new List<T>();
foreach (var element in parent.Elements(propertyName))
{
T elementResult;
if (!rootElementDeserializer(element, out elementResult))
{
return false;
}
result.Add(elementResult);
}
return true;
};
}
internal static XmlDeserializer<IDictionary<string, T>> CreateDictionaryXmlDeserializer<T>( XmlDeserializer<T> elementDeserializer )
{
return (XElement parent, string propertyName, out IDictionary<string, T> result) => {
result = null;
var childElement = parent.Element(propertyName);
if (childElement == null)
{
return false;
}
result = new Dictionary<string, T>();
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

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,839 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Petstore
{
using Models;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Extension methods for SwaggerPetstore.
/// </summary>
public static partial class SwaggerPetstoreExtensions
{
/// <summary>
/// Fake endpoint to test byte array in body parameter for adding a new pet to
/// the store
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Pet object in the form of byte array
/// </param>
public static void AddPetUsingByteArray(this ISwaggerPetstore operations, string body = default(string))
{
operations.AddPetUsingByteArrayAsync(body).GetAwaiter().GetResult();
}
/// <summary>
/// Fake endpoint to test byte array in body parameter for adding a new pet to
/// the store
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Pet object in the form of byte array
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <remarks>
/// Adds a new pet to the store. You may receive an HTTP invalid input if your
/// pet is invalid.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Pet object that needs to be added to the store
/// </param>
public static void AddPet(this ISwaggerPetstore operations, Pet body = default(Pet))
{
operations.AddPetAsync(body).GetAwaiter().GetResult();
}
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <remarks>
/// Adds a new pet to the store. You may receive an HTTP invalid input if your
/// pet is invalid.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Pet object that needs to be added to the store
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Update an existing pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Pet object that needs to be added to the store
/// </param>
public static void UpdatePet(this ISwaggerPetstore operations, Pet body = default(Pet))
{
operations.UpdatePetAsync(body).GetAwaiter().GetResult();
}
/// <summary>
/// Update an existing pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Pet object that needs to be added to the store
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Finds Pets by status
/// </summary>
/// <remarks>
/// Multiple status values can be provided with comma seperated strings
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='status'>
/// Status values that need to be considered for filter
/// </param>
public static IList<Pet> FindPetsByStatus(this ISwaggerPetstore operations, IList<string> status = default(IList<string>))
{
return operations.FindPetsByStatusAsync(status).GetAwaiter().GetResult();
}
/// <summary>
/// Finds Pets by status
/// </summary>
/// <remarks>
/// Multiple status values can be provided with comma seperated strings
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='status'>
/// Status values that need to be considered for filter
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<Pet>> FindPetsByStatusAsync(this ISwaggerPetstore operations, IList<string> status = default(IList<string>), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.FindPetsByStatusWithHttpMessagesAsync(status, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Finds Pets by tags
/// </summary>
/// <remarks>
/// Muliple tags can be provided with comma seperated strings. Use tag1, tag2,
/// tag3 for testing.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='tags'>
/// Tags to filter by
/// </param>
public static IList<Pet> FindPetsByTags(this ISwaggerPetstore operations, IList<string> tags = default(IList<string>))
{
return operations.FindPetsByTagsAsync(tags).GetAwaiter().GetResult();
}
/// <summary>
/// Finds Pets by tags
/// </summary>
/// <remarks>
/// Muliple tags can be provided with comma seperated strings. Use tag1, tag2,
/// tag3 for testing.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='tags'>
/// Tags to filter by
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<Pet>> FindPetsByTagsAsync(this ISwaggerPetstore operations, IList<string> tags = default(IList<string>), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.FindPetsByTagsWithHttpMessagesAsync(tags, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Fake endpoint to test byte array return by 'Find pet by ID'
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API
/// error conditions
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet that needs to be fetched
/// </param>
public static string FindPetsWithByteArray(this ISwaggerPetstore operations, long petId)
{
return operations.FindPetsWithByteArrayAsync(petId).GetAwaiter().GetResult();
}
/// <summary>
/// Fake endpoint to test byte array return by 'Find pet by ID'
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API
/// error conditions
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet that needs to be fetched
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<string> FindPetsWithByteArrayAsync(this ISwaggerPetstore operations, long petId, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.FindPetsWithByteArrayWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Find pet by ID
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API
/// error conditions
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet that needs to be fetched
/// </param>
public static Pet GetPetById(this ISwaggerPetstore operations, long petId)
{
return operations.GetPetByIdAsync(petId).GetAwaiter().GetResult();
}
/// <summary>
/// Find pet by ID
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API
/// error conditions
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet that needs to be fetched
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Pet> GetPetByIdAsync(this ISwaggerPetstore operations, long petId, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GetPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet that needs to be updated
/// </param>
/// <param name='name'>
/// Updated name of the pet
/// </param>
/// <param name='status'>
/// Updated status of the pet
/// </param>
public static void UpdatePetWithForm(this ISwaggerPetstore operations, string petId, string name = default(string), string status = default(string))
{
operations.UpdatePetWithFormAsync(petId, name, status).GetAwaiter().GetResult();
}
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet that needs to be updated
/// </param>
/// <param name='name'>
/// Updated name of the pet
/// </param>
/// <param name='status'>
/// Updated status of the pet
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// Pet id to delete
/// </param>
/// <param name='apiKey'>
/// </param>
public static void DeletePet(this ISwaggerPetstore operations, long petId, string apiKey = default(string))
{
operations.DeletePetAsync(petId, apiKey).GetAwaiter().GetResult();
}
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// Pet id to delete
/// </param>
/// <param name='apiKey'>
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// uploads an image
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet to update
/// </param>
/// <param name='additionalMetadata'>
/// Additional data to pass to server
/// </param>
/// <param name='file'>
/// file to upload
/// </param>
public static void UploadFile(this ISwaggerPetstore operations, long petId, string additionalMetadata = default(string), Stream file = default(Stream))
{
operations.UploadFileAsync(petId, additionalMetadata, file).GetAwaiter().GetResult();
}
/// <summary>
/// uploads an image
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// ID of pet to update
/// </param>
/// <param name='additionalMetadata'>
/// Additional data to pass to server
/// </param>
/// <param name='file'>
/// file to upload
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Returns pet inventories by status
/// </summary>
/// <remarks>
/// Returns a map of status codes to quantities
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
public static IDictionary<string, int?> GetInventory(this ISwaggerPetstore operations)
{
return operations.GetInventoryAsync().GetAwaiter().GetResult();
}
/// <summary>
/// Returns pet inventories by status
/// </summary>
/// <remarks>
/// Returns a map of status codes to quantities
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IDictionary<string, int?>> GetInventoryAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GetInventoryWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Place an order for a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// order placed for purchasing the pet
/// </param>
public static Order PlaceOrder(this ISwaggerPetstore operations, Order body = default(Order))
{
return operations.PlaceOrderAsync(body).GetAwaiter().GetResult();
}
/// <summary>
/// Place an order for a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// order placed for purchasing the pet
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Order> 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;
}
}
/// <summary>
/// Find purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other
/// values will generated exceptions
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='orderId'>
/// ID of pet that needs to be fetched
/// </param>
public static Order GetOrderById(this ISwaggerPetstore operations, string orderId)
{
return operations.GetOrderByIdAsync(orderId).GetAwaiter().GetResult();
}
/// <summary>
/// Find purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other
/// values will generated exceptions
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='orderId'>
/// ID of pet that needs to be fetched
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Order> GetOrderByIdAsync(this ISwaggerPetstore operations, string orderId, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GetOrderByIdWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Delete purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt; 1000. Anything above
/// 1000 or nonintegers will generate API errors
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='orderId'>
/// ID of the order that needs to be deleted
/// </param>
public static void DeleteOrder(this ISwaggerPetstore operations, string orderId)
{
operations.DeleteOrderAsync(orderId).GetAwaiter().GetResult();
}
/// <summary>
/// Delete purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt; 1000. Anything above
/// 1000 or nonintegers will generate API errors
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='orderId'>
/// ID of the order that needs to be deleted
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task DeleteOrderAsync(this ISwaggerPetstore operations, string orderId, CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.DeleteOrderWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false)).Dispose();
}
/// <summary>
/// Create user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Created user object
/// </param>
public static void CreateUser(this ISwaggerPetstore operations, User body = default(User))
{
operations.CreateUserAsync(body).GetAwaiter().GetResult();
}
/// <summary>
/// Create user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// Created user object
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// List of user object
/// </param>
public static void CreateUsersWithArrayInput(this ISwaggerPetstore operations, IList<User> body = default(IList<User>))
{
operations.CreateUsersWithArrayInputAsync(body).GetAwaiter().GetResult();
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// List of user object
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task CreateUsersWithArrayInputAsync(this ISwaggerPetstore operations, IList<User> body = default(IList<User>), CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.CreateUsersWithArrayInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// List of user object
/// </param>
public static void CreateUsersWithListInput(this ISwaggerPetstore operations, IList<User> body = default(IList<User>))
{
operations.CreateUsersWithListInputAsync(body).GetAwaiter().GetResult();
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='body'>
/// List of user object
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task CreateUsersWithListInputAsync(this ISwaggerPetstore operations, IList<User> body = default(IList<User>), CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.CreateUsersWithListInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
}
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// The user name for login
/// </param>
/// <param name='password'>
/// The password for login in clear text
/// </param>
public static string LoginUser(this ISwaggerPetstore operations, string username = default(string), string password = default(string))
{
return operations.LoginUserAsync(username, password).GetAwaiter().GetResult();
}
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// The user name for login
/// </param>
/// <param name='password'>
/// The password for login in clear text
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<string> 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;
}
}
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
public static void LogoutUser(this ISwaggerPetstore operations)
{
operations.LogoutUserAsync().GetAwaiter().GetResult();
}
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task LogoutUserAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.LogoutUserWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose();
}
/// <summary>
/// Get user by user name
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// The name that needs to be fetched. Use user1 for testing.
/// </param>
public static User GetUserByName(this ISwaggerPetstore operations, string username)
{
return operations.GetUserByNameAsync(username).GetAwaiter().GetResult();
}
/// <summary>
/// Get user by user name
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// The name that needs to be fetched. Use user1 for testing.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<User> GetUserByNameAsync(this ISwaggerPetstore operations, string username, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GetUserByNameWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Updated user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// name that need to be deleted
/// </param>
/// <param name='body'>
/// Updated user object
/// </param>
public static void UpdateUser(this ISwaggerPetstore operations, string username, User body = default(User))
{
operations.UpdateUserAsync(username, body).GetAwaiter().GetResult();
}
/// <summary>
/// Updated user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// name that need to be deleted
/// </param>
/// <param name='body'>
/// Updated user object
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Delete user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// The name that needs to be deleted
/// </param>
public static void DeleteUser(this ISwaggerPetstore operations, string username)
{
operations.DeleteUserAsync(username).GetAwaiter().GetResult();
}
/// <summary>
/// Delete user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='username'>
/// The name that needs to be deleted
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task DeleteUserAsync(this ISwaggerPetstore operations, string username, CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.DeleteUserWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false)).Dispose();
}
}
}
SRC

Просмотреть файл

@ -1,100 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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;
/// <summary>
/// </summary>
public partial interface ISwaggerPetstore : System.IDisposable
{
/// <summary>
/// The base URI of the service.
/// </summary>
System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
JsonSerializerSettings SerializationSettings { get; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
JsonSerializerSettings DeserializationSettings { get; }
/// <summary>
/// Credentials needed for the client to connect to Azure.
/// </summary>
ServiceClientCredentials Credentials { get; }
/// <summary>
/// Gets or sets the preferred language for the response.
/// </summary>
string AcceptLanguage { get; set; }
/// <summary>
/// Gets or sets the retry timeout in seconds for Long Running
/// Operations. Default value is 30.
/// </summary>
int? LongRunningOperationRetryTimeout { get; set; }
/// <summary>
/// When set to true a unique x-ms-client-request-id value is generated
/// and included in each request. Default is true.
/// </summary>
bool? GenerateClientRequestId { get; set; }
/// <summary>
/// List all pets
/// </summary>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<AzureOperationResponse<IList<PetInner>,ListPetsHeadersInner>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Create a pet
/// </summary>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<AzureOperationResponse> CreatePetsWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<AzureOperationResponse<IList<PetInner>>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,62 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
public partial class Error
{
/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error(int code, string message)
{
Code = code;
Message = message;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "code")]
public int Code { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Message == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Message");
}
}
}
}
SRC

Просмотреть файл

@ -1,57 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Microsoft.Rest;
/// <summary>
/// Exception thrown for an invalid response with Error information.
/// </summary>
public class ErrorException : RestException
{
/// <summary>
/// Gets information about the associated HTTP request.
/// </summary>
public HttpRequestMessageWrapper Request { get; set; }
/// <summary>
/// Gets information about the associated HTTP response.
/// </summary>
public HttpResponseMessageWrapper Response { get; set; }
/// <summary>
/// Gets or sets the body object.
/// </summary>
public Error Body { get; set; }
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
public ErrorException()
{
}
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
/// <param name="message">The exception message.</param>
public ErrorException(string message)
: this(message, null)
{
}
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
/// <param name="message">The exception message.</param>
/// <param name="innerException">Inner exception.</param>
public ErrorException(string message, System.Exception innerException)
: base(message, innerException)
{
}
}
}
SRC

Просмотреть файл

@ -1,47 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// Defines headers for listPets operation.
/// </summary>
public partial class ListPetsHeadersInner
{
/// <summary>
/// Initializes a new instance of the ListPetsHeadersInner class.
/// </summary>
public ListPetsHeadersInner()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the ListPetsHeadersInner class.
/// </summary>
/// <param name="xNext">A link to the next page of responses</param>
public ListPetsHeadersInner(string xNext = default(string))
{
XNext = xNext;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets a link to the next page of responses
/// </summary>
[JsonProperty(PropertyName = "x-next")]
public string XNext { get; set; }
}
}
SRC

Просмотреть файл

@ -1,68 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
public partial class PetInner
{
/// <summary>
/// Initializes a new instance of the PetInner class.
/// </summary>
public PetInner()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the PetInner class.
/// </summary>
public PetInner(long id, string name, string tag = default(string))
{
Id = id;
Name = name;
Tag = tag;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "id")]
public long Id { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "tag")]
public string Tag { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Name == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Name");
}
}
}
}
SRC

Просмотреть файл

@ -1,772 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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<SwaggerPetstore>, ISwaggerPetstore, IAzureClient
{
/// <summary>
/// The base URI of the service.
/// </summary>
public System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
public JsonSerializerSettings SerializationSettings { get; private set; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
public JsonSerializerSettings DeserializationSettings { get; private set; }
/// <summary>
/// Credentials needed for the client to connect to Azure.
/// </summary>
public ServiceClientCredentials Credentials { get; private set; }
/// <summary>
/// Gets or sets the preferred language for the response.
/// </summary>
public string AcceptLanguage { get; set; }
/// <summary>
/// Gets or sets the retry timeout in seconds for Long Running Operations.
/// Default value is 30.
/// </summary>
public int? LongRunningOperationRetryTimeout { get; set; }
/// <summary>
/// When set to true a unique x-ms-client-request-id value is generated and
/// included in each request. Default is true.
/// </summary>
public bool? GenerateClientRequestId { get; set; }
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
protected SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers)
{
Initialize();
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
protected SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
{
Initialize();
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// An optional partial-method to perform custom initialization.
/// </summary>
partial void CustomInitialize();
/// <summary>
/// Initializes client properties.
/// </summary>
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<JsonConverter>
{
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<JsonConverter>
{
new Iso8601TimeSpanConverter()
}
};
CustomInitialize();
DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
}
/// <summary>
/// List all pets
/// </summary>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IList<PetInner>,ListPetsHeadersInner>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
if (_shouldTrace)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<Error>(_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<IList<PetInner>,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<IList<PetInner>>(_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<ListPetsHeadersInner>(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;
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse> CreatePetsWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
if (_shouldTrace)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<Error>(_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;
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IList<PetInner>>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<Error>(_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<IList<PetInner>>();
_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<IList<PetInner>>(_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

Просмотреть файл

@ -1,116 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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;
/// <summary>
/// Extension methods for SwaggerPetstore.
/// </summary>
public static partial class SwaggerPetstoreExtensions
{
/// <summary>
/// List all pets
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
public static IList<PetInner> ListPets(this ISwaggerPetstore operations, int? limit = default(int?))
{
return operations.ListPetsAsync(limit).GetAwaiter().GetResult();
}
/// <summary>
/// List all pets
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<PetInner>> 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;
}
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
public static void CreatePets(this ISwaggerPetstore operations)
{
operations.CreatePetsAsync().GetAwaiter().GetResult();
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task CreatePetsAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.CreatePetsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose();
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
public static IList<PetInner> ShowPetById(this ISwaggerPetstore operations, string petId)
{
return operations.ShowPetByIdAsync(petId).GetAwaiter().GetResult();
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<PetInner>> 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

Просмотреть файл

@ -1,100 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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;
/// <summary>
/// </summary>
public partial interface ISwaggerPetstoreClient : System.IDisposable
{
/// <summary>
/// The base URI of the service.
/// </summary>
System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
JsonSerializerSettings SerializationSettings { get; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
JsonSerializerSettings DeserializationSettings { get; }
/// <summary>
/// Credentials needed for the client to connect to Azure.
/// </summary>
ServiceClientCredentials Credentials { get; }
/// <summary>
/// Gets or sets the preferred language for the response.
/// </summary>
string AcceptLanguage { get; set; }
/// <summary>
/// Gets or sets the retry timeout in seconds for Long Running
/// Operations. Default value is 30.
/// </summary>
int? LongRunningOperationRetryTimeout { get; set; }
/// <summary>
/// When set to true a unique x-ms-client-request-id value is generated
/// and included in each request. Default is true.
/// </summary>
bool? GenerateClientRequestId { get; set; }
/// <summary>
/// List all pets
/// </summary>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<AzureOperationResponse<IList<Pet>,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Create a pet
/// </summary>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<AzureOperationResponse> CreatePetsWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<AzureOperationResponse<IList<Pet>>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,62 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
public partial class Error
{
/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error(int code, string message)
{
Code = code;
Message = message;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "code")]
public int Code { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Message == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Message");
}
}
}
}
SRC

Просмотреть файл

@ -1,57 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Microsoft.Rest;
/// <summary>
/// Exception thrown for an invalid response with Error information.
/// </summary>
public class ErrorException : RestException
{
/// <summary>
/// Gets information about the associated HTTP request.
/// </summary>
public HttpRequestMessageWrapper Request { get; set; }
/// <summary>
/// Gets information about the associated HTTP response.
/// </summary>
public HttpResponseMessageWrapper Response { get; set; }
/// <summary>
/// Gets or sets the body object.
/// </summary>
public Error Body { get; set; }
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
public ErrorException()
{
}
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
/// <param name="message">The exception message.</param>
public ErrorException(string message)
: this(message, null)
{
}
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
/// <param name="message">The exception message.</param>
/// <param name="innerException">Inner exception.</param>
public ErrorException(string message, System.Exception innerException)
: base(message, innerException)
{
}
}
}
SRC

Просмотреть файл

@ -1,47 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// Defines headers for listPets operation.
/// </summary>
public partial class ListPetsHeaders
{
/// <summary>
/// Initializes a new instance of the ListPetsHeaders class.
/// </summary>
public ListPetsHeaders()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the ListPetsHeaders class.
/// </summary>
/// <param name="xNext">A link to the next page of responses</param>
public ListPetsHeaders(string xNext = default(string))
{
XNext = xNext;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets a link to the next page of responses
/// </summary>
[JsonProperty(PropertyName = "x-next")]
public string XNext { get; set; }
}
}
SRC

Просмотреть файл

@ -1,68 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace cowstore.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
public partial class Pet
{
/// <summary>
/// Initializes a new instance of the Pet class.
/// </summary>
public Pet()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Pet class.
/// </summary>
public Pet(long id, string name, string tag = default(string))
{
Id = id;
Name = name;
Tag = tag;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "id")]
public long Id { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "tag")]
public string Tag { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Name == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Name");
}
}
}
}
SRC

Просмотреть файл

@ -1,772 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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<SwaggerPetstoreClient>, ISwaggerPetstoreClient, IAzureClient
{
/// <summary>
/// The base URI of the service.
/// </summary>
public System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
public JsonSerializerSettings SerializationSettings { get; private set; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
public JsonSerializerSettings DeserializationSettings { get; private set; }
/// <summary>
/// Credentials needed for the client to connect to Azure.
/// </summary>
public ServiceClientCredentials Credentials { get; private set; }
/// <summary>
/// Gets or sets the preferred language for the response.
/// </summary>
public string AcceptLanguage { get; set; }
/// <summary>
/// Gets or sets the retry timeout in seconds for Long Running Operations.
/// Default value is 30.
/// </summary>
public int? LongRunningOperationRetryTimeout { get; set; }
/// <summary>
/// When set to true a unique x-ms-client-request-id value is generated and
/// included in each request. Default is true.
/// </summary>
public bool? GenerateClientRequestId { get; set; }
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
protected SwaggerPetstoreClient(params DelegatingHandler[] handlers) : base(handlers)
{
Initialize();
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
protected SwaggerPetstoreClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
{
Initialize();
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected SwaggerPetstoreClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected SwaggerPetstoreClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstoreClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// An optional partial-method to perform custom initialization.
/// </summary>
partial void CustomInitialize();
/// <summary>
/// Initializes client properties.
/// </summary>
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<JsonConverter>
{
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<JsonConverter>
{
new Iso8601TimeSpanConverter()
}
};
CustomInitialize();
DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
}
/// <summary>
/// List all pets
/// </summary>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IList<Pet>,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
if (_shouldTrace)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<Error>(_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<IList<Pet>,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<IList<Pet>>(_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<ListPetsHeaders>(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;
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse> CreatePetsWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
if (_shouldTrace)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<Error>(_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;
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IList<Pet>>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<Error>(_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<IList<Pet>>();
_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<IList<Pet>>(_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

Просмотреть файл

@ -1,116 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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;
/// <summary>
/// Extension methods for SwaggerPetstoreClient.
/// </summary>
public static partial class SwaggerPetstoreClientExtensions
{
/// <summary>
/// List all pets
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
public static IList<Pet> ListPets(this ISwaggerPetstoreClient operations, int? limit = default(int?))
{
return operations.ListPetsAsync(limit).GetAwaiter().GetResult();
}
/// <summary>
/// List all pets
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<Pet>> 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;
}
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
public static void CreatePets(this ISwaggerPetstoreClient operations)
{
operations.CreatePetsAsync().GetAwaiter().GetResult();
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task CreatePetsAsync(this ISwaggerPetstoreClient operations, CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.CreatePetsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose();
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
public static IList<Pet> ShowPetById(this ISwaggerPetstoreClient operations, string petId)
{
return operations.ShowPetByIdAsync(petId).GetAwaiter().GetResult();
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<Pet>> 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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<ResponseBody> 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<ResponseBody> response, final Error body) {
super(message, response, body);
}
@Override
public Error body() {
return (Error) super.body();
}
}
SRC

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<Response<ResponseBody>> 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<Response<ResponseBody>> 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<Response<ResponseBody>> 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&lt;PetInner&gt; object if successful.
*/
public List<PetInner> 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<List<PetInner>> listPetsAsync(final ServiceCallback<List<PetInner>> serviceCallback) {
return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(), serviceCallback);
}
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;PetInner&gt; object
*/
public Observable<List<PetInner>> listPetsAsync() {
return listPetsWithServiceResponseAsync().map(new Func1<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>, List<PetInner>>() {
@Override
public List<PetInner> call(ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner> response) {
return response.body();
}
});
}
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;PetInner&gt; object
*/
public Observable<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>> listPetsWithServiceResponseAsync() {
final Integer limit = null;
return service.listPets(limit, this.acceptLanguage(), this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>>>() {
@Override
public Observable<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>> call(Response<ResponseBody> response) {
try {
ServiceResponseWithHeaders<List<PetInner>, 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&lt;PetInner&gt; object if successful.
*/
public List<PetInner> 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<List<PetInner>> listPetsAsync(Integer limit, final ServiceCallback<List<PetInner>> 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&lt;PetInner&gt; object
*/
public Observable<List<PetInner>> listPetsAsync(Integer limit) {
return listPetsWithServiceResponseAsync(limit).map(new Func1<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>, List<PetInner>>() {
@Override
public List<PetInner> call(ServiceResponseWithHeaders<List<PetInner>, 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&lt;PetInner&gt; object
*/
public Observable<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>> listPetsWithServiceResponseAsync(Integer limit) {
return service.listPets(limit, this.acceptLanguage(), this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>>>() {
@Override
public Observable<ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner>> call(Response<ResponseBody> response) {
try {
ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner> clientResponse = listPetsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponseWithHeaders<List<PetInner>, ListPetsHeadersInner> listPetsDelegate(Response<ResponseBody> response) throws ErrorException, IOException {
return this.restClient().responseBuilderFactory().<List<PetInner>, ErrorException>newInstance(this.serializerAdapter())
.register(200, new TypeToken<List<PetInner>>() { }.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<Void> createPetsAsync(final ServiceCallback<Void> 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<Void> createPetsAsync() {
return createPetsWithServiceResponseAsync().map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
/**
* Create a pet.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<ServiceResponse<Void>> createPetsWithServiceResponseAsync() {
return service.createPets(this.acceptLanguage(), this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
@Override
public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Void> clientResponse = createPetsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<Void> createPetsDelegate(Response<ResponseBody> response) throws ErrorException, IOException {
return this.restClient().responseBuilderFactory().<Void, ErrorException>newInstance(this.serializerAdapter())
.register(201, new TypeToken<Void>() { }.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&lt;PetInner&gt; object if successful.
*/
public List<PetInner> 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<List<PetInner>> showPetByIdAsync(String petId, final ServiceCallback<List<PetInner>> 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&lt;PetInner&gt; object
*/
public Observable<List<PetInner>> showPetByIdAsync(String petId) {
return showPetByIdWithServiceResponseAsync(petId).map(new Func1<ServiceResponse<List<PetInner>>, List<PetInner>>() {
@Override
public List<PetInner> call(ServiceResponse<List<PetInner>> 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&lt;PetInner&gt; object
*/
public Observable<ServiceResponse<List<PetInner>>> 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<Response<ResponseBody>, Observable<ServiceResponse<List<PetInner>>>>() {
@Override
public Observable<ServiceResponse<List<PetInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<List<PetInner>> clientResponse = showPetByIdDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<List<PetInner>> showPetByIdDelegate(Response<ResponseBody> response) throws ErrorException, IOException, IllegalArgumentException {
return this.restClient().responseBuilderFactory().<List<PetInner>, ErrorException>newInstance(this.serializerAdapter())
.register(200, new TypeToken<List<PetInner>>() { }.getType())
.registerError(ErrorException.class)
.build(response);
}
}
SRC

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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&lt;Pet&gt; object if successful.
*/
List<Pet> 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<List<Pet>> listPetsAsync(final ServiceCallback<List<Pet>> serviceCallback);
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
Observable<List<Pet>> listPetsAsync();
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
Observable<ServiceResponseWithHeaders<List<Pet>, 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&lt;Pet&gt; object if successful.
*/
List<Pet> 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<List<Pet>> listPetsAsync(Integer limit, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<ServiceResponseWithHeaders<List<Pet>, 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<Void> createPetsAsync(final ServiceCallback<Void> serviceCallback);
/**
* Create a pet.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
Observable<Void> createPetsAsync();
/**
* Create a pet.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
Observable<ServiceResponse<Void>> 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&lt;Pet&gt; object if successful.
*/
List<Pet> 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<List<Pet>> showPetByIdAsync(String petId, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<ServiceResponse<List<Pet>>> showPetByIdWithServiceResponseAsync(String petId);
}
SRC

Просмотреть файл

@ -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<Response<ResponseBody>> 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<Response<ResponseBody>> 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<Response<ResponseBody>> 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&lt;Pet&gt; object if successful.
*/
public List<Pet> 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<List<Pet>> listPetsAsync(final ServiceCallback<List<Pet>> serviceCallback) {
return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(), serviceCallback);
}
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
public Observable<List<Pet>> listPetsAsync() {
return listPetsWithServiceResponseAsync().map(new Func1<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>, List<Pet>>() {
@Override
public List<Pet> call(ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders> response) {
return response.body();
}
});
}
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> listPetsWithServiceResponseAsync() {
final Integer limit = null;
return service.listPets(limit, this.acceptLanguage(), this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> call(Response<ResponseBody> response) {
try {
ServiceResponseWithHeaders<List<Pet>, 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&lt;Pet&gt; object if successful.
*/
public List<Pet> 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<List<Pet>> listPetsAsync(Integer limit, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
public Observable<List<Pet>> listPetsAsync(Integer limit) {
return listPetsWithServiceResponseAsync(limit).map(new Func1<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>, List<Pet>>() {
@Override
public List<Pet> call(ServiceResponseWithHeaders<List<Pet>, 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&lt;Pet&gt; object
*/
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> listPetsWithServiceResponseAsync(Integer limit) {
return service.listPets(limit, this.acceptLanguage(), this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> call(Response<ResponseBody> response) {
try {
ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders> clientResponse = listPetsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders> listPetsDelegate(Response<ResponseBody> response) throws ErrorException, IOException {
return this.restClient().responseBuilderFactory().<List<Pet>, ErrorException>newInstance(this.serializerAdapter())
.register(200, new TypeToken<List<Pet>>() { }.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<Void> createPetsAsync(final ServiceCallback<Void> 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<Void> createPetsAsync() {
return createPetsWithServiceResponseAsync().map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
/**
* Create a pet.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<ServiceResponse<Void>> createPetsWithServiceResponseAsync() {
return service.createPets(this.acceptLanguage(), this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
@Override
public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Void> clientResponse = createPetsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<Void> createPetsDelegate(Response<ResponseBody> response) throws ErrorException, IOException {
return this.restClient().responseBuilderFactory().<Void, ErrorException>newInstance(this.serializerAdapter())
.register(201, new TypeToken<Void>() { }.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&lt;Pet&gt; object if successful.
*/
public List<Pet> 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<List<Pet>> showPetByIdAsync(String petId, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
public Observable<List<Pet>> showPetByIdAsync(String petId) {
return showPetByIdWithServiceResponseAsync(petId).map(new Func1<ServiceResponse<List<Pet>>, List<Pet>>() {
@Override
public List<Pet> call(ServiceResponse<List<Pet>> 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&lt;Pet&gt; object
*/
public Observable<ServiceResponse<List<Pet>>> 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<Response<ResponseBody>, Observable<ServiceResponse<List<Pet>>>>() {
@Override
public Observable<ServiceResponse<List<Pet>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<List<Pet>> clientResponse = showPetByIdDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<List<Pet>> showPetByIdDelegate(Response<ResponseBody> response) throws ErrorException, IOException, IllegalArgumentException {
return this.restClient().responseBuilderFactory().<List<Pet>, ErrorException>newInstance(this.serializerAdapter())
.register(200, new TypeToken<List<Pet>>() { }.getType())
.registerError(ErrorException.class)
.build(response);
}
}
SRC

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<ResponseBody> 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<ResponseBody> response, final Error body) {
super(message, response, body);
}
@Override
public Error body() {
return (Error) super.body();
}
}
SRC

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<Array>} - 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<null>} - 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<Array>} - 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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -1,77 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace CSharpNamespace
{
using Microsoft.Rest;
using Models;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// </summary>
public partial interface ISwaggerPetstore : System.IDisposable
{
/// <summary>
/// The base URI of the service.
/// </summary>
System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
JsonSerializerSettings SerializationSettings { get; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
JsonSerializerSettings DeserializationSettings { get; }
/// <summary>
/// List all pets
/// </summary>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<IList<Pet>,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Create a pet
/// </summary>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> CreatePetsWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse<IList<Pet>>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,62 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace CSharpNamespace.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
public partial class Error
{
/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error(int code, string message)
{
Code = code;
Message = message;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "code")]
public int Code { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Message == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Message");
}
}
}
}
SRC

Просмотреть файл

@ -1,57 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace CSharpNamespace.Models
{
using Microsoft.Rest;
/// <summary>
/// Exception thrown for an invalid response with Error information.
/// </summary>
public class ErrorException : RestException
{
/// <summary>
/// Gets information about the associated HTTP request.
/// </summary>
public HttpRequestMessageWrapper Request { get; set; }
/// <summary>
/// Gets information about the associated HTTP response.
/// </summary>
public HttpResponseMessageWrapper Response { get; set; }
/// <summary>
/// Gets or sets the body object.
/// </summary>
public Error Body { get; set; }
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
public ErrorException()
{
}
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
/// <param name="message">The exception message.</param>
public ErrorException(string message)
: this(message, null)
{
}
/// <summary>
/// Initializes a new instance of the ErrorException class.
/// </summary>
/// <param name="message">The exception message.</param>
/// <param name="innerException">Inner exception.</param>
public ErrorException(string message, System.Exception innerException)
: base(message, innerException)
{
}
}
}
SRC

Просмотреть файл

@ -1,47 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace CSharpNamespace.Models
{
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// Defines headers for listPets operation.
/// </summary>
public partial class ListPetsHeaders
{
/// <summary>
/// Initializes a new instance of the ListPetsHeaders class.
/// </summary>
public ListPetsHeaders()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the ListPetsHeaders class.
/// </summary>
/// <param name="xNext">A link to the next page of responses</param>
public ListPetsHeaders(string xNext = default(string))
{
XNext = xNext;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets a link to the next page of responses
/// </summary>
[JsonProperty(PropertyName = "x-next")]
public string XNext { get; set; }
}
}
SRC

Просмотреть файл

@ -1,68 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace CSharpNamespace.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
public partial class Pet
{
/// <summary>
/// Initializes a new instance of the Pet class.
/// </summary>
public Pet()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Pet class.
/// </summary>
public Pet(long id, string name, string tag = default(string))
{
Id = id;
Name = name;
Tag = tag;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "id")]
public long Id { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "tag")]
public string Tag { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Name == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Name");
}
}
}
}
SRC

Просмотреть файл

@ -1,546 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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<SwaggerPetstore>, ISwaggerPetstore
{
/// <summary>
/// The base URI of the service.
/// </summary>
public System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
public JsonSerializerSettings SerializationSettings { get; private set; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
public JsonSerializerSettings DeserializationSettings { get; private set; }
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
public SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers)
{
Initialize();
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
public SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
{
Initialize();
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}
/// <summary>
/// Initializes a new instance of the SwaggerPetstore class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}
/// <summary>
/// An optional partial-method to perform custom initialization.
///</summary>
partial void CustomInitialize();
/// <summary>
/// Initializes client properties.
/// </summary>
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<JsonConverter>
{
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<JsonConverter>
{
new Iso8601TimeSpanConverter()
}
};
CustomInitialize();
}
/// <summary>
/// List all pets
/// </summary>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<IList<Pet>,ListPetsHeaders>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
if (_shouldTrace)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<Error>(_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<IList<Pet>,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<IList<Pet>>(_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<ListPetsHeaders>(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;
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse> CreatePetsWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
if (_shouldTrace)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
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<Error>(_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;
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<IList<Pet>>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<Error>(_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<IList<Pet>>();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
// Deserialize Response
if ((int)_statusCode == 200)
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
_result.Body = SafeJsonConvert.DeserializeObject<IList<Pet>>(_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

Просмотреть файл

@ -1,114 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace CSharpNamespace
{
using Models;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Extension methods for SwaggerPetstore.
/// </summary>
public static partial class SwaggerPetstoreExtensions
{
/// <summary>
/// List all pets
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
public static IList<Pet> ListPets(this ISwaggerPetstore operations, int? limit = default(int?))
{
return operations.ListPetsAsync(limit).GetAwaiter().GetResult();
}
/// <summary>
/// List all pets
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='limit'>
/// How many items to return at one time (max 100)
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<Pet>> 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;
}
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
public static void CreatePets(this ISwaggerPetstore operations)
{
operations.CreatePetsAsync().GetAwaiter().GetResult();
}
/// <summary>
/// Create a pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task CreatePetsAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.CreatePetsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose();
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
public static IList<Pet> ShowPetById(this ISwaggerPetstore operations, string petId)
{
return operations.ShowPetByIdAsync(petId).GetAwaiter().GetResult();
}
/// <summary>
/// Info for a specific pet
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='petId'>
/// The id of the pet to retrieve
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<Pet>> 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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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&lt;Pet&gt; object if successful.
*/
List<Pet> 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<List<Pet>> listPetsAsync(final ServiceCallback<List<Pet>> serviceCallback);
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
Observable<List<Pet>> listPetsAsync();
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
Observable<ServiceResponseWithHeaders<List<Pet>, 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&lt;Pet&gt; object if successful.
*/
List<Pet> 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<List<Pet>> listPetsAsync(Integer limit, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<ServiceResponseWithHeaders<List<Pet>, 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<Void> createPetsAsync(final ServiceCallback<Void> serviceCallback);
/**
* Create a pet.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
Observable<Void> createPetsAsync();
/**
* Create a pet.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
Observable<ServiceResponse<Void>> 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&lt;Pet&gt; object if successful.
*/
List<Pet> 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<List<Pet>> showPetByIdAsync(String petId, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<List<Pet>> 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&lt;Pet&gt; object
*/
Observable<ServiceResponse<List<Pet>>> showPetByIdWithServiceResponseAsync(String petId);
}
SRC

Просмотреть файл

@ -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<Response<ResponseBody>> listPets(@Query("limit") Integer limit);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: javanamespace.SwaggerPetstore createPets" })
@POST("pets")
Observable<Response<ResponseBody>> createPets();
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: javanamespace.SwaggerPetstore showPetById" })
@GET("pets/{petId}")
Observable<Response<ResponseBody>> 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&lt;Pet&gt; object if successful.
*/
public List<Pet> 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<List<Pet>> listPetsAsync(final ServiceCallback<List<Pet>> serviceCallback) {
return ServiceFuture.fromHeaderResponse(listPetsWithServiceResponseAsync(), serviceCallback);
}
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
public Observable<List<Pet>> listPetsAsync() {
return listPetsWithServiceResponseAsync().map(new Func1<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>, List<Pet>>() {
@Override
public List<Pet> call(ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders> response) {
return response.body();
}
});
}
/**
* List all pets.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;Pet&gt; object
*/
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> listPetsWithServiceResponseAsync() {
final Integer limit = null;
return service.listPets(limit)
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> call(Response<ResponseBody> response) {
try {
ServiceResponseWithHeaders<List<Pet>, 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&lt;Pet&gt; object if successful.
*/
public List<Pet> 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<List<Pet>> listPetsAsync(Integer limit, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
public Observable<List<Pet>> listPetsAsync(Integer limit) {
return listPetsWithServiceResponseAsync(limit).map(new Func1<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>, List<Pet>>() {
@Override
public List<Pet> call(ServiceResponseWithHeaders<List<Pet>, 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&lt;Pet&gt; object
*/
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> listPetsWithServiceResponseAsync(Integer limit) {
return service.listPets(limit)
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders>> call(Response<ResponseBody> response) {
try {
ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders> clientResponse = listPetsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponseWithHeaders<List<Pet>, ListPetsHeaders> listPetsDelegate(Response<ResponseBody> response) throws ErrorException, IOException {
return this.restClient().responseBuilderFactory().<List<Pet>, ErrorException>newInstance(this.serializerAdapter())
.register(200, new TypeToken<List<Pet>>() { }.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<Void> createPetsAsync(final ServiceCallback<Void> 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<Void> createPetsAsync() {
return createPetsWithServiceResponseAsync().map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
/**
* Create a pet.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<ServiceResponse<Void>> createPetsWithServiceResponseAsync() {
return service.createPets()
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
@Override
public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Void> clientResponse = createPetsDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<Void> createPetsDelegate(Response<ResponseBody> response) throws ErrorException, IOException {
return this.restClient().responseBuilderFactory().<Void, ErrorException>newInstance(this.serializerAdapter())
.register(201, new TypeToken<Void>() { }.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&lt;Pet&gt; object if successful.
*/
public List<Pet> 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<List<Pet>> showPetByIdAsync(String petId, final ServiceCallback<List<Pet>> 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&lt;Pet&gt; object
*/
public Observable<List<Pet>> showPetByIdAsync(String petId) {
return showPetByIdWithServiceResponseAsync(petId).map(new Func1<ServiceResponse<List<Pet>>, List<Pet>>() {
@Override
public List<Pet> call(ServiceResponse<List<Pet>> 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&lt;Pet&gt; object
*/
public Observable<ServiceResponse<List<Pet>>> showPetByIdWithServiceResponseAsync(String petId) {
if (petId == null) {
throw new IllegalArgumentException("Parameter petId is required and cannot be null.");
}
return service.showPetById(petId)
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<Pet>>>>() {
@Override
public Observable<ServiceResponse<List<Pet>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<List<Pet>> clientResponse = showPetByIdDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<List<Pet>> showPetByIdDelegate(Response<ResponseBody> response) throws ErrorException, IOException, IllegalArgumentException {
return this.restClient().responseBuilderFactory().<List<Pet>, ErrorException>newInstance(this.serializerAdapter())
.register(200, new TypeToken<List<Pet>>() { }.getType())
.registerError(ErrorException.class)
.build(response);
}
}
SRC

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<ResponseBody> 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<ResponseBody> response, final Error body) {
super(message, response, body);
}
@Override
public Error body() {
return (Error) super.body();
}
}
SRC

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<Array>} - 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<null>} - 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<Array>} - 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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -1,879 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
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;
/// <summary>
/// DataSources operations.
/// </summary>
public partial class DataSources : IServiceOperations<SearchandStorage>, IDataSources
{
/// <summary>
/// Initializes a new instance of the DataSources class.
/// </summary>
/// <param name='client'>
/// Reference to the service client.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public DataSources(SearchandStorage client)
{
if (client == null)
{
throw new System.ArgumentNullException("client");
}
Client = client;
}
/// <summary>
/// Gets a reference to the SearchandStorage
/// </summary>
public SearchandStorage Client { get; private set; }
/// <summary>
/// Creates a new Azure Search datasource or updates a datasource if it already
/// exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn946900.aspx" />
/// </summary>
/// <param name='dataSourceName'>
/// The name of the datasource to create or update.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<DataSource>> CreateOrUpdateWithHttpMessagesAsync(string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<DataSource>();
_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<DataSource>(_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<DataSource>(_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;
}
/// <summary>
/// Deletes an Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946881.aspx" />
/// </summary>
/// <param name='dataSourceName'>
/// The name of the datasource to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse> DeleteWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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;
}
/// <summary>
/// Retrieves a datasource definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn946893.aspx" />
/// </summary>
/// <param name='dataSourceName'>
/// The name of the datasource to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<DataSource>> GetWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<DataSource>();
_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<DataSource>(_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;
}
/// <summary>
/// Lists all datasources available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn946878.aspx" />
/// </summary>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<DataSourceListResult>> ListWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<DataSourceListResult>();
_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<DataSourceListResult>(_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;
}
/// <summary>
/// Creates a new Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946876.aspx" />
/// </summary>
/// <param name='dataSource'>
/// The definition of the datasource to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<DataSource>> CreateWithHttpMessagesAsync(DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>();
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<string> _queryParameters = new List<string>();
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<DataSource>();
_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<DataSource>(_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

Просмотреть файл

@ -1,228 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Models;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Extension methods for DataSources.
/// </summary>
public static partial class DataSourcesExtensions
{
/// <summary>
/// Creates a new Azure Search datasource or updates a datasource if it already
/// exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn946900.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSourceName'>
/// The name of the datasource to create or update.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static DataSource CreateOrUpdate(this IDataSources operations, string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.CreateOrUpdateAsync(dataSourceName, dataSource, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Creates a new Azure Search datasource or updates a datasource if it already
/// exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn946900.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSourceName'>
/// The name of the datasource to create or update.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<DataSource> 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;
}
}
/// <summary>
/// Deletes an Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946881.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSourceName'>
/// The name of the datasource to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static void Delete(this IDataSources operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
operations.DeleteAsync(dataSourceName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Deletes an Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946881.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSourceName'>
/// The name of the datasource to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Retrieves a datasource definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn946893.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSourceName'>
/// The name of the datasource to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static DataSource Get(this IDataSources operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.GetAsync(dataSourceName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Retrieves a datasource definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn946893.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSourceName'>
/// The name of the datasource to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<DataSource> 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;
}
}
/// <summary>
/// Lists all datasources available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn946878.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static DataSourceListResult List(this IDataSources operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.ListAsync(searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Lists all datasources available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn946878.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<DataSourceListResult> 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;
}
}
/// <summary>
/// Creates a new Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946876.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static DataSource Create(this IDataSources operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.CreateAsync(dataSource, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Creates a new Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946876.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<DataSource> 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

Просмотреть файл

@ -1,150 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Microsoft.Rest;
using Models;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// DataSources operations.
/// </summary>
public partial interface IDataSources
{
/// <summary>
/// Creates a new Azure Search datasource or updates a datasource if it
/// already exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn946900.aspx" />
/// </summary>
/// <param name='dataSourceName'>
/// The name of the datasource to create or update.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<DataSource>> CreateOrUpdateWithHttpMessagesAsync(string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Deletes an Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946881.aspx" />
/// </summary>
/// <param name='dataSourceName'>
/// The name of the datasource to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse> DeleteWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves a datasource definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn946893.aspx" />
/// </summary>
/// <param name='dataSourceName'>
/// The name of the datasource to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<DataSource>> GetWithHttpMessagesAsync(string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Lists all datasources available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn946878.aspx" />
/// </summary>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<DataSourceListResult>> ListWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates a new Azure Search datasource.
/// <see href="https://msdn.microsoft.com/library/azure/dn946876.aspx" />
/// </summary>
/// <param name='dataSource'>
/// The definition of the datasource to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<DataSource>> CreateWithHttpMessagesAsync(DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,223 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Microsoft.Rest;
using Models;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Indexers operations.
/// </summary>
public partial interface IIndexers
{
/// <summary>
/// Resets the change tracking state associated with an Azure Search
/// indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946897.aspx" />
/// </summary>
/// <param name='indexerName'>
/// The name of the indexer to reset.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse> ResetWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Runs an Azure Search indexer on-demand.
/// <see href="https://msdn.microsoft.com/library/azure/dn946885.aspx" />
/// </summary>
/// <param name='indexerName'>
/// The name of the indexer to run.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse> RunWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates a new Azure Search indexer or updates an indexer if it
/// already exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" />
/// </summary>
/// <param name='indexerName'>
/// The name of the indexer to create or update.
/// </param>
/// <param name='indexer'>
/// The definition of the indexer to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<Indexer>> CreateOrUpdateWithHttpMessagesAsync(string indexerName, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Deletes an Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946898.aspx" />
/// </summary>
/// <param name='indexerName'>
/// The name of the indexer to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse> DeleteWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves an indexer definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn946874.aspx" />
/// </summary>
/// <param name='indexerName'>
/// The name of the indexer to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<Indexer>> GetWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Lists all indexers available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn946883.aspx" />
/// </summary>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<IndexerListResult>> ListWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates a new Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" />
/// </summary>
/// <param name='indexer'>
/// The definition of the indexer to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<Indexer>> CreateWithHttpMessagesAsync(Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Returns the current status and execution history of an indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946884.aspx" />
/// </summary>
/// <param name='indexerName'>
/// The name of the indexer for which to retrieve status.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<IndexerExecutionInfo>> GetStatusWithHttpMessagesAsync(string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,182 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Microsoft.Rest;
using Models;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Indexes operations.
/// </summary>
public partial interface IIndexes
{
/// <summary>
/// Creates a new Azure Search index.
/// <see href="https://msdn.microsoft.com/library/azure/dn798941.aspx" />
/// </summary>
/// <param name='index'>
/// The definition of the index to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<Index>> CreateWithHttpMessagesAsync(Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Lists all indexes available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn798923.aspx" />
/// </summary>
/// <param name='select'>
/// 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.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<IndexListResult>> ListWithHttpMessagesAsync(string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates a new Azure Search index or updates an index if it already
/// exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn800964.aspx" />
/// </summary>
/// <param name='indexName'>
/// The definition of the index to create or update.
/// </param>
/// <param name='index'>
/// The definition of the index to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<Index>> CreateOrUpdateWithHttpMessagesAsync(string indexName, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Deletes an Azure Search index and all the documents it contains.
/// <see href="https://msdn.microsoft.com/library/azure/dn798926.aspx" />
/// </summary>
/// <param name='indexName'>
/// The name of the index to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse> DeleteWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves an index definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn798939.aspx" />
/// </summary>
/// <param name='indexName'>
/// The name of the index to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<Index>> GetWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Returns statistics for the given index, including a document count
/// and storage usage.
/// <see href="https://msdn.microsoft.com/library/azure/dn798942.aspx" />
/// </summary>
/// <param name='indexName'>
/// The name of the index for which to retrieve statistics.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<IndexGetStatisticsResult>> GetStatisticsWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,65 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Models;
using Newtonsoft.Json;
/// <summary>
/// </summary>
public partial interface ISearchandStorage : System.IDisposable
{
/// <summary>
/// The base URI of the service.
/// </summary>
System.Uri BaseUri { get; set; }
/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
JsonSerializerSettings SerializationSettings { get; }
/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
JsonSerializerSettings DeserializationSettings { get; }
/// <summary>
/// Gets subscription credentials which uniquely identify Microsoft
/// Azure subscription. The subscription ID forms part of the URI for
/// every service call.
/// </summary>
string SubscriptionId { get; set; }
/// <summary>
/// Gets the IDataSources.
/// </summary>
IDataSources DataSources { get; }
/// <summary>
/// Gets the IIndexers.
/// </summary>
IIndexers Indexers { get; }
/// <summary>
/// Gets the IIndexes.
/// </summary>
IIndexes Indexes { get; }
/// <summary>
/// Gets the IStorageAccounts.
/// </summary>
IStorageAccounts StorageAccounts { get; }
/// <summary>
/// Gets the IUsageOperations.
/// </summary>
IUsageOperations Usage { get; }
}
}
SRC

Просмотреть файл

@ -1,278 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Microsoft.Rest;
using Models;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// StorageAccounts operations.
/// </summary>
public partial interface IStorageAccounts
{
/// <summary>
/// Checks that account name is valid and is not in use.
/// </summary>
/// <param name='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>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<CheckNameAvailabilityResult>> CheckNameAvailabilityWithHttpMessagesAsync(StorageAccountCheckNameAvailabilityParameters accountName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// 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.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group within the user's subscription.
/// </param>
/// <param name='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>
/// <param name='parameters'>
/// The parameters to provide for the created account.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<StorageAccount>> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Deletes a storage account in Microsoft Azure.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group within the user's subscription.
/// </param>
/// <param name='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>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// 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.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group within the user's subscription.
/// </param>
/// <param name='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>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<StorageAccount>> GetPropertiesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// 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.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group within the user's subscription.
/// </param>
/// <param name='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>
/// <param name='parameters'>
/// The parameters to update on the account. Note that only one
/// property can be changed at a time using this API.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<StorageAccount>> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Lists the access keys for the specified storage account.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group.
/// </param>
/// <param name='accountName'>
/// The name of the storage account.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<StorageAccountKeys>> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Lists all the storage accounts available under the subscription.
/// Note that storage keys are not returned; use the ListKeys operation
/// for this.
/// </summary>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<StorageAccountListResult>> ListWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Lists all the storage accounts available under the given resource
/// group. Note that storage keys are not returned; use the ListKeys
/// operation for this.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group within the user's subscription.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<StorageAccountListResult>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Regenerates the access keys for the specified storage account.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group within the user's subscription.
/// </param>
/// <param name='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>
/// <param name='regenerateKey'>
/// Specifies name of the key which should be regenerated. key1 or key2
/// for the default keys
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<StorageAccountKeys>> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, StorageAccountRegenerateKeyParameters regenerateKey, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Просмотреть файл

@ -1,42 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Microsoft.Rest;
using Models;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// UsageOperations operations.
/// </summary>
public partial interface IUsageOperations
{
/// <summary>
/// Gets the current usage count and the limit for the resources under
/// the subscription.
/// </summary>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.HttpOperationException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<UsageListResult>> ListWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
SRC

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,348 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Models;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Extension methods for Indexers.
/// </summary>
public static partial class IndexersExtensions
{
/// <summary>
/// Resets the change tracking state associated with an Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946897.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to reset.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static void Reset(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
operations.ResetAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Resets the change tracking state associated with an Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946897.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to reset.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Runs an Azure Search indexer on-demand.
/// <see href="https://msdn.microsoft.com/library/azure/dn946885.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to run.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static void Run(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
operations.RunAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Runs an Azure Search indexer on-demand.
/// <see href="https://msdn.microsoft.com/library/azure/dn946885.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to run.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Creates a new Azure Search indexer or updates an indexer if it already
/// exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to create or update.
/// </param>
/// <param name='indexer'>
/// The definition of the indexer to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static Indexer CreateOrUpdate(this IIndexers operations, string indexerName, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.CreateOrUpdateAsync(indexerName, indexer, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Creates a new Azure Search indexer or updates an indexer if it already
/// exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to create or update.
/// </param>
/// <param name='indexer'>
/// The definition of the indexer to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Indexer> 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;
}
}
/// <summary>
/// Deletes an Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946898.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static void Delete(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
operations.DeleteAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Deletes an Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946898.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Retrieves an indexer definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn946874.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static Indexer Get(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.GetAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Retrieves an indexer definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn946874.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Indexer> 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;
}
}
/// <summary>
/// Lists all indexers available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn946883.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static IndexerListResult List(this IIndexers operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.ListAsync(searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Lists all indexers available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn946883.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IndexerListResult> 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;
}
}
/// <summary>
/// Creates a new Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexer'>
/// The definition of the indexer to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static Indexer Create(this IIndexers operations, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.CreateAsync(indexer, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Creates a new Azure Search indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexer'>
/// The definition of the indexer to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Indexer> 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;
}
}
/// <summary>
/// Returns the current status and execution history of an indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946884.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer for which to retrieve status.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static IndexerExecutionInfo GetStatus(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.GetStatusAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Returns the current status and execution history of an indexer.
/// <see href="https://msdn.microsoft.com/library/azure/dn946884.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexerName'>
/// The name of the indexer for which to retrieve status.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IndexerExecutionInfo> 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

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,280 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice
{
using Models;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Extension methods for Indexes.
/// </summary>
public static partial class IndexesExtensions
{
/// <summary>
/// Creates a new Azure Search index.
/// <see href="https://msdn.microsoft.com/library/azure/dn798941.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='index'>
/// The definition of the index to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static Index Create(this IIndexes operations, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.CreateAsync(index, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Creates a new Azure Search index.
/// <see href="https://msdn.microsoft.com/library/azure/dn798941.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='index'>
/// The definition of the index to create.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Index> 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;
}
}
/// <summary>
/// Lists all indexes available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn798923.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='select'>
/// 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.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static IndexListResult List(this IIndexes operations, string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.ListAsync(select, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Lists all indexes available for an Azure Search service.
/// <see href="https://msdn.microsoft.com/library/azure/dn798923.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='select'>
/// 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.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IndexListResult> 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;
}
}
/// <summary>
/// Creates a new Azure Search index or updates an index if it already exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn800964.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The definition of the index to create or update.
/// </param>
/// <param name='index'>
/// The definition of the index to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static Index CreateOrUpdate(this IIndexes operations, string indexName, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.CreateOrUpdateAsync(indexName, index, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Creates a new Azure Search index or updates an index if it already exists.
/// <see href="https://msdn.microsoft.com/library/azure/dn800964.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The definition of the index to create or update.
/// </param>
/// <param name='index'>
/// The definition of the index to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Index> 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;
}
}
/// <summary>
/// Deletes an Azure Search index and all the documents it contains.
/// <see href="https://msdn.microsoft.com/library/azure/dn798926.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The name of the index to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static void Delete(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
operations.DeleteAsync(indexName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Deletes an Azure Search index and all the documents it contains.
/// <see href="https://msdn.microsoft.com/library/azure/dn798926.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The name of the index to delete.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
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();
}
/// <summary>
/// Retrieves an index definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn798939.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The name of the index to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static Index Get(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.GetAsync(indexName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Retrieves an index definition from Azure Search.
/// <see href="https://msdn.microsoft.com/library/azure/dn798939.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The name of the index to retrieve.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Index> 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;
}
}
/// <summary>
/// Returns statistics for the given index, including a document count and
/// storage usage.
/// <see href="https://msdn.microsoft.com/library/azure/dn798942.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The name of the index for which to retrieve statistics.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
public static IndexGetStatisticsResult GetStatistics(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.GetStatisticsAsync(indexName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Returns statistics for the given index, including a document count and
/// storage usage.
/// <see href="https://msdn.microsoft.com/library/azure/dn798942.aspx" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='indexName'>
/// The name of the index for which to retrieve statistics.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IndexGetStatisticsResult> 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

Просмотреть файл

@ -1,56 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime;
using System.Runtime.Serialization;
/// <summary>
/// Defines values for AccountStatus.
/// </summary>
[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

Просмотреть файл

@ -1,74 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime;
using System.Runtime.Serialization;
/// <summary>
/// Defines values for AccountType.
/// </summary>
[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

Просмотреть файл

@ -1,76 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// The CheckNameAvailability operation response.
/// </summary>
public partial class CheckNameAvailabilityResult
{
/// <summary>
/// Initializes a new instance of the CheckNameAvailabilityResult
/// class.
/// </summary>
public CheckNameAvailabilityResult()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the CheckNameAvailabilityResult
/// class.
/// </summary>
/// <param name="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.</param>
/// <param name="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'</param>
/// <param name="message">Gets an error message explaining the Reason
/// value in more detail.</param>
public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string))
{
NameAvailable = nameAvailable;
Reason = reason;
Message = message;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// 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.
/// </summary>
[JsonProperty(PropertyName = "nameAvailable")]
public bool? NameAvailable { get; set; }
/// <summary>
/// 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'
/// </summary>
[JsonProperty(PropertyName = "reason")]
public Reason? Reason { get; set; }
/// <summary>
/// Gets an error message explaining the Reason value in more detail.
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }
}
}
SRC

Просмотреть файл

@ -1,83 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Defines options to control Cross-Origin Resource Sharing (CORS) for an
/// index.
/// <see href="https://msdn.microsoft.com/library/azure/dn798941.aspx" />
/// </summary>
public partial class CorsOptions
{
/// <summary>
/// Initializes a new instance of the CorsOptions class.
/// </summary>
public CorsOptions()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the CorsOptions class.
/// </summary>
/// <param name="allowedOrigins">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).</param>
/// <param name="maxAgeInSeconds">Gets or sets the duration for which
/// browsers should cache CORS preflight responses. Defaults to 5
/// mintues.</param>
public CorsOptions(IList<string> allowedOrigins, long? maxAgeInSeconds = default(long?))
{
AllowedOrigins = allowedOrigins;
MaxAgeInSeconds = maxAgeInSeconds;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// 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).
/// </summary>
[JsonProperty(PropertyName = "allowedOrigins")]
public IList<string> AllowedOrigins { get; set; }
/// <summary>
/// Gets or sets the duration for which browsers should cache CORS
/// preflight responses. Defaults to 5 mintues.
/// </summary>
[JsonProperty(PropertyName = "maxAgeInSeconds")]
public long? MaxAgeInSeconds { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (AllowedOrigins == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "AllowedOrigins");
}
}
}
}
SRC

Просмотреть файл

@ -1,74 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// The custom domain assigned to this storage account. This can be set via
/// Update.
/// </summary>
public partial class CustomDomain
{
/// <summary>
/// Initializes a new instance of the CustomDomain class.
/// </summary>
public CustomDomain()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the CustomDomain class.
/// </summary>
/// <param name="name">Gets or sets the custom domain name. Name is the
/// CNAME source.</param>
/// <param name="useSubDomain">Indicates whether indirect CName
/// validation is enabled. Default value is false. This should only be
/// set on updates</param>
public CustomDomain(string name, bool? useSubDomain = default(bool?))
{
Name = name;
UseSubDomain = useSubDomain;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets the custom domain name. Name is the CNAME source.
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// Gets or sets indicates whether indirect CName validation is
/// enabled. Default value is false. This should only be set on updates
/// </summary>
[JsonProperty(PropertyName = "useSubDomain")]
public bool? UseSubDomain { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Name == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Name");
}
}
}
}
SRC

Просмотреть файл

@ -1,31 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using System.Linq;
/// <summary>
/// Abstract base class for data change detection policies.
/// </summary>
public partial class DataChangeDetectionPolicy
{
/// <summary>
/// Initializes a new instance of the DataChangeDetectionPolicy class.
/// </summary>
public DataChangeDetectionPolicy()
{
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
}
}
SRC

Просмотреть файл

@ -1,76 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// Represents information about the entity (such as Azure SQL table or
/// DocumentDb collection) that will be indexed.
/// </summary>
public partial class DataContainer
{
/// <summary>
/// Initializes a new instance of the DataContainer class.
/// </summary>
public DataContainer()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the DataContainer class.
/// </summary>
/// <param name="name">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.</param>
/// <param name="query">Gets or sets a query that is applied to this
/// data container. Only supported by DocumentDb datasources.</param>
public DataContainer(string name, string query = default(string))
{
Name = name;
Query = query;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// 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.
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// Gets or sets a query that is applied to this data container. Only
/// supported by DocumentDb datasources.
/// </summary>
[JsonProperty(PropertyName = "query")]
public string Query { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Name == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Name");
}
}
}
}
SRC

Просмотреть файл

@ -1,32 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using System.Linq;
/// <summary>
/// Abstract base class for data deletion detection policies.
/// </summary>
public partial class DataDeletionDetectionPolicy
{
/// <summary>
/// Initializes a new instance of the DataDeletionDetectionPolicy
/// class.
/// </summary>
public DataDeletionDetectionPolicy()
{
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
}
}
SRC

Просмотреть файл

@ -1,135 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// Represents a datasource definition in Azure Search, which can be used
/// to configure an indexer.
/// </summary>
public partial class DataSource
{
/// <summary>
/// Initializes a new instance of the DataSource class.
/// </summary>
public DataSource()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the DataSource class.
/// </summary>
/// <param name="name">Gets or sets the name of the datasource.</param>
/// <param name="type">Gets or sets the type of the datasource.</param>
/// <param name="credentials">Gets or sets credentials for the
/// datasource.</param>
/// <param name="container">Gets or sets the data container for the
/// datasource.</param>
/// <param name="description">Gets or sets the description of the
/// datasource.</param>
/// <param name="dataChangeDetectionPolicy">Gets or sets the data
/// change detection policy for the datasource.</param>
/// <param name="dataDeletionDetectionPolicy">Gets or sets the data
/// deletion detection policy for the datasource.</param>
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();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets the name of the datasource.
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// Gets or sets the description of the datasource.
/// </summary>
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }
/// <summary>
/// Gets or sets the type of the datasource.
/// </summary>
[JsonProperty(PropertyName = "type")]
public string Type { get; set; }
/// <summary>
/// Gets or sets credentials for the datasource.
/// </summary>
[JsonProperty(PropertyName = "credentials")]
public DataSourceCredentials Credentials { get; set; }
/// <summary>
/// Gets or sets the data container for the datasource.
/// </summary>
[JsonProperty(PropertyName = "container")]
public DataContainer Container { get; set; }
/// <summary>
/// Gets or sets the data change detection policy for the datasource.
/// </summary>
[JsonProperty(PropertyName = "dataChangeDetectionPolicy")]
public DataChangeDetectionPolicy DataChangeDetectionPolicy { get; set; }
/// <summary>
/// Gets or sets the data deletion detection policy for the datasource.
/// </summary>
[JsonProperty(PropertyName = "dataDeletionDetectionPolicy")]
public DataDeletionDetectionPolicy DataDeletionDetectionPolicy { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
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

Просмотреть файл

@ -1,62 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// Represents credentials that can be used to connect to a datasource.
/// </summary>
public partial class DataSourceCredentials
{
/// <summary>
/// Initializes a new instance of the DataSourceCredentials class.
/// </summary>
public DataSourceCredentials()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the DataSourceCredentials class.
/// </summary>
/// <param name="connectionString">Gets or sets the connection string
/// for the datasource.</param>
public DataSourceCredentials(string connectionString)
{
ConnectionString = connectionString;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets or sets the connection string for the datasource.
/// </summary>
[JsonProperty(PropertyName = "connectionString")]
public string ConnectionString { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (ConnectionString == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "ConnectionString");
}
}
}
}
SRC

Просмотреть файл

@ -1,72 +1 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace Searchservice.Models
{
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// The URIs that are used to perform a retrieval of a public blob, queue
/// or table object.
/// </summary>
public partial class Endpoints
{
/// <summary>
/// Initializes a new instance of the Endpoints class.
/// </summary>
public Endpoints()
{
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Endpoints class.
/// </summary>
/// <param name="blob">Gets the blob endpoint.</param>
/// <param name="queue">Gets the queue endpoint.</param>
/// <param name="table">Gets the table endpoint.</param>
/// <param name="file">Gets the file endpoint.</param>
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();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();
/// <summary>
/// Gets the blob endpoint.
/// </summary>
[JsonProperty(PropertyName = "blob")]
public string Blob { get; set; }
/// <summary>
/// Gets the queue endpoint.
/// </summary>
[JsonProperty(PropertyName = "queue")]
public string Queue { get; set; }
/// <summary>
/// Gets the table endpoint.
/// </summary>
[JsonProperty(PropertyName = "table")]
public string Table { get; set; }
/// <summary>
/// Gets the file endpoint.
/// </summary>
[JsonProperty(PropertyName = "file")]
public string File { get; set; }
}
}
SRC

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше