From 8a2fd9ab80621a79a90eecdc467e4a2a2a2d008a Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Sat, 7 May 2016 23:01:41 +0530 Subject: [PATCH 01/23] Update ServiceClient.cs --- .../ServiceClient.cs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index 6763f4e6641f..8051c80557e3 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -207,10 +207,38 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params FirstMessageHandler = currentHandler; HttpClient = newClient; Type type = this.GetType(); - HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, + //setting userAgentBelow is removed because now the client can set it using SetUserAgent method + /* HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, + GetClientVersion()));*/ + } + + //A mehtod to set user agent + public bool SetUserAgent(string produtName) + { + if(!_disposed && HttpClient != null) + { + HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, GetClientVersion())); + // returns true if the userAgent was added + return true; + } + // returns false if the httpclient was disposed before invoking the method + return false; + } + + //Another method to setuseragent and it's version + + public bool SetUserAgent(string produtName,string version) + { + if(!_disposed && HttpClient != null) + { + HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version); + // returns true if the userAgent was added + return true; + } + // returns false if the httpclient was disposed before invoking the method + return false; } - /// /// Gets the AssemblyInformationalVersion if available /// if not it gets the AssemblyFileVerion From 79b30937cc4bbc376cc604a9bfffec07fc2efcc9 Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Sat, 7 May 2016 23:03:48 +0530 Subject: [PATCH 02/23] Update ServiceClient.cs --- .../CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index 8051c80557e3..8871933963ae 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -217,8 +217,7 @@ public bool SetUserAgent(string produtName) { if(!_disposed && HttpClient != null) { - HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, - GetClientVersion())); + HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, GetClientVersion())); // returns true if the userAgent was added return true; } From 328825f82e7aa1ac94c146a42f3d68652d901937 Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Tue, 17 May 2016 00:23:42 +0530 Subject: [PATCH 03/23] Update ServiceClient.cs --- .../CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index 8871933963ae..d6ae6d7146e8 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -213,7 +213,7 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params } //A mehtod to set user agent - public bool SetUserAgent(string produtName) + public bool SetUserAgent(string productName) { if(!_disposed && HttpClient != null) { @@ -227,7 +227,7 @@ public bool SetUserAgent(string produtName) //Another method to setuseragent and it's version - public bool SetUserAgent(string produtName,string version) + public bool SetUserAgent(string productName,string version) { if(!_disposed && HttpClient != null) { From ca5a350fd366332b21e8549bcc96e4206e7b6f24 Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Tue, 17 May 2016 07:36:44 +0530 Subject: [PATCH 04/23] Update ServiceClient.cs --- .../Microsoft.Rest.ClientRuntime/ServiceClient.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index d6ae6d7146e8..78142ca5759b 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -208,8 +208,8 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params HttpClient = newClient; Type type = this.GetType(); //setting userAgentBelow is removed because now the client can set it using SetUserAgent method - /* HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, - GetClientVersion()));*/ + HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, + GetClientVersion())); } //A mehtod to set user agent @@ -217,6 +217,10 @@ public bool SetUserAgent(string productName) { if(!_disposed && HttpClient != null) { + /// + /// Dispose the the old useragent. + /// + HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, GetClientVersion())); // returns true if the userAgent was added return true; @@ -231,6 +235,10 @@ public bool SetUserAgent(string productName,string version) { if(!_disposed && HttpClient != null) { + /// + /// Dispose the the old useragent. + /// + HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version); // returns true if the userAgent was added return true; From 2c27c28eb867b4c059e8e1c363e5282ad48f5a49 Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Tue, 17 May 2016 07:38:34 +0530 Subject: [PATCH 05/23] Update ServiceClient.cs --- .../CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index 78142ca5759b..4012b737cf69 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -207,7 +207,6 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params FirstMessageHandler = currentHandler; HttpClient = newClient; Type type = this.GetType(); - //setting userAgentBelow is removed because now the client can set it using SetUserAgent method HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, GetClientVersion())); } From 4630b69e45ab1448a40d9c76f9ef3eccac60d460 Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Wed, 18 May 2016 23:37:30 +0530 Subject: [PATCH 06/23] Update ServiceClient.cs --- .../CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index 4012b737cf69..104af8135770 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -238,7 +238,7 @@ public bool SetUserAgent(string productName,string version) /// Dispose the the old useragent. /// HttpClient.DefaultRequestHeaders.UserAgent.Clear(); - HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version); + HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version)); // returns true if the userAgent was added return true; } From 4624e6f04a96201ad3fa55ee176cc46243418c9f Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Thu, 19 May 2016 00:07:26 +0530 Subject: [PATCH 07/23] Update ServiceClient.cs --- .../ServiceClient.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index 104af8135770..bba5be03f8a2 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -210,8 +210,9 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, GetClientVersion())); } - - //A mehtod to set user agent + /// + ///A mehtod to set user agent + /// public bool SetUserAgent(string productName) { if(!_disposed && HttpClient != null) @@ -224,12 +225,14 @@ public bool SetUserAgent(string productName) // returns true if the userAgent was added return true; } - // returns false if the httpclient was disposed before invoking the method + /// + ///returns false if the httpclient was disposed before invoking the method + /// return false; } - - //Another method to setuseragent and it's version - + /// + ///Another method to setuseragent and its version + /// public bool SetUserAgent(string productName,string version) { if(!_disposed && HttpClient != null) @@ -239,10 +242,14 @@ public bool SetUserAgent(string productName,string version) /// HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version)); - // returns true if the userAgent was added + /// + // returns true if the userAgent was added + /// return true; } - // returns false if the httpclient was disposed before invoking the method + /// + /// returns false if the httpclient was disposed before invoking the method + /// return false; } /// From 0ba790bc48463ea2de9776caa67b4c05aaac8787 Mon Sep 17 00:00:00 2001 From: TimLovellSmith Date: Fri, 20 May 2016 11:58:29 -0700 Subject: [PATCH 08/23] Fix Swagger SchemaResolver to allow for the fact that properties may be defined by chains of indirect references to some type which inherits from another compatible type - and that should be fine! --- .../AutoRest.Modeler.Swagger.Tests.csproj | 4 + .../Swagger/swagger-redis-sample.json | 683 ++++++++++++++++++ .../Swagger.Tests/SwaggerModelerRedisTests.cs | 35 + AutoRest/Modelers/Swagger/SchemaResolver.cs | 49 +- 4 files changed, 756 insertions(+), 15 deletions(-) create mode 100644 AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json create mode 100644 AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs diff --git a/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj b/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj index ea2b011b5341..dda50548a36d 100644 --- a/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj +++ b/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj @@ -36,9 +36,13 @@ True Resources.resx + + + PreserveNewest + PreserveNewest diff --git a/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json b/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json new file mode 100644 index 000000000000..bf80d0515b19 --- /dev/null +++ b/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json @@ -0,0 +1,683 @@ +{ + "swagger": "2.0", + "info": { + "title": "RedisManagementClient", + "description": "REST API for Azure Redis Cache Service", + "version": "2016-04-01" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "flow": "implicit", + "description": "Azure Active Directory OAuth2 Flow", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "put": { + "tags": [ + "Redis" + ], + "operationId": "Redis_CreateOrUpdate", + "description": "Create a redis cache, or replace (overwrite/recreate, with potential downtime) an existing cache", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the redis cache." + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RedisCreateOrUpdateParameters" + }, + "description": "Parameters supplied to the CreateOrUpdate redis operation." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/RedisResourceWithAccessKey" + } + }, + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/RedisResourceWithAccessKey" + } + } + } + }, + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a redis cache. This operation takes a while to complete.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + }, + "get": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Get", + "description": "Gets a redis cache (resource description).", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/RedisResource" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/": { + "get": { + "tags": [ + "Redis" + ], + "operationId": "Redis_ListByResourceGroup", + "description": "Gets all redis caches in a resource group.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/RedisListResult" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/Redis/": { + "get": { + "tags": [ + "Redis" + ], + "operationId": "Redis_List", + "description": "Gets all redis caches in the specified subscription.", + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/RedisListResult" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/listKeys": { + "post": { + "tags": [ + "Redis" + ], + "operationId": "Redis_ListKeys", + "description": "Retrieve a redis cache's access keys. This operation requires write permission to the cache resource.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Lists the keys for Redis Cache", + "schema": { + "$ref": "#/definitions/RedisListKeysResult" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/regenerateKey": { + "post": { + "tags": [ + "Redis" + ], + "operationId": "Redis_RegenerateKey", + "description": "Regenerate redis cache's access keys. This operation requires write permission to the cache resource.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the redis cache." + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RedisRegenerateKeyParameters" + }, + "description": "Specifies which key to reset." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Lists the regenerated keys for Redis Cache", + "schema": { + "$ref": "#/definitions/RedisListKeysResult" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/forceReboot": { + "post": { + "tags": [ + "Redis" + ], + "operationId": "Redis_ForceReboot", + "description": "Reboot specified redis node(s). This operation requires write permission to the cache resource. There can be potential data loss.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the redis cache." + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RedisRebootParameters" + }, + "description": "Specifies which redis node(s) to reboot." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + } + } + }, + "definitions": { + "Sku": { + "properties": { + "name": { + "type": "string", + "description": "What type of redis cache to deploy. Valid values: (Basic, Standard, Premium)", + "enum": [ + "Basic", + "Standard", + "Premium" + ], + "x-ms-enum": { + "name": "SkuName", + "modelAsString": true + } + }, + "family": { + "type": "string", + "description": "Which family to use. Valid values: (C, P)", + "enum": [ + "C", + "P" + ], + "x-ms-enum": { + "name": "SkuFamily", + "modelAsString": true + } + }, + "capacity": { + "type": "integer", + "format": "int32", + "description": "What size of redis cache to deploy. Valid values: for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4)" + } + }, + "required": [ + "name", + "family", + "capacity" + ], + "description": "Sku parameters supplied to the create redis operation." + }, + "RedisProperties": { + "properties": { + "redisVersion": { + "type": "string", + "description": "RedisVersion parameter has been deprecated. As such, it is no longer necessary to provide this parameter and any value specified is ignored." + }, + "sku": { + "$ref": "#/definitions/Sku", + "description": "What sku of redis cache to deploy." + }, + "redisConfiguration": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value etc." + }, + "enableNonSslPort": { + "type": "boolean", + "description": "If the value is true, then the non-ssl redis server port (6379) will be enabled." + }, + "tenantSettings": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "tenantSettings" + }, + "shardCount": { + "type": "integer", + "format": "int32", + "description": "The number of shards to be created on a Premium Cluster Cache." + }, + "subnetId": { + "type": "string", + "description": "The full resource ID of a subnet in a virtual network to deploy the redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1" + }, + "staticIP": { + "type": "string", + "description": "Required when deploying a redis cache inside an existing Azure Virtual Network." + } + }, + "required": [ + "sku" + ], + "description": "Parameters supplied to CreateOrUpdate redis operation." + }, + "Resource": { + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id" + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + }, + "RedisCreateOrUpdateParameters": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/RedisProperties", + "description": "Redis cache properties." + } + }, + "required": [ + "properties" + ], + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "Parameters supplied to the CreateOrUpdate Redis operation." + }, + "RedisAccessKeys": { + "properties": { + "primaryKey": { + "type": "string", + "description": "The current primary key that clients can use to authenticate with redis cache." + }, + "secondaryKey": { + "type": "string", + "description": "The current secondary key that clients can use to authenticate with redis cache." + } + }, + "description": "Redis cache access keys." + }, + "RedisReadableProperties": { + "properties": { + "provisioningState": { + "type": "string", + "description": "Redis instance provisioning status" + }, + "hostName": { + "type": "string", + "description": "Redis host name" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "Redis non-ssl port" + }, + "sslPort": { + "type": "integer", + "format": "int32", + "description": "Redis ssl port" + } + }, + "allOf": [ + { + "$ref": "#/definitions/RedisProperties" + } + ], + "description": "Parameters describing a redis instance" + }, + "RedisReadablePropertiesWithAccessKey": { + "properties": { + "accessKeys": { + "$ref": "#/definitions/RedisAccessKeys", + "description": "Redis cache access keys." + } + }, + "allOf": [ + { + "$ref": "#/definitions/RedisReadableProperties" + } + ], + "description": "Properties generated only in response to CreateOrUpdate redis operation." + }, + "RedisResourceWithAccessKey": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/RedisReadablePropertiesWithAccessKey", + "description": "Redis cache properties" + } + }, + "allOf": [ + { + "$ref": "#/definitions/RedisResource" + } + ], + "description": "A redis item in CreateOrUpdate Operation response." + }, + "RedisResource": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/RedisReadableProperties", + "description": "Redis cache properties" + } + }, + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "A single redis item in List or Get Operation." + }, + "RedisListResult": { + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/RedisResource" + }, + "description": "Results of the list operation" + }, + "nextLink": { + "type": "string", + "description": "Link for next set of locations." + } + }, + "description": "The response of list redis operation." + }, + "RedisListKeysResult": { + "properties": { + "primaryKey": { + "type": "string", + "description": "The current primary key that clients can use to authenticate with redis cache." + }, + "secondaryKey": { + "type": "string", + "description": "The current secondary key that clients can use to authenticate with redis cache." + } + }, + "description": "The response of redis list keys operation." + }, + "RedisRegenerateKeyParameters": { + "properties": { + "keyType": { + "type": "string", + "description": "Which redis access key to reset", + "enum": [ + "Primary", + "Secondary" + ], + "x-ms-enum": { + "name": "RedisKeyType", + "modelAsString": false + } + } + }, + "required": [ + "keyType" + ], + "description": "Specifies which redis access keys to reset." + }, + "RedisRebootParameters": { + "properties": { + "rebootType": { + "type": "string", + "description": "Which redis node(s) to reboot. Depending on this value data loss is possible.", + "enum": [ + "PrimaryNode", + "SecondaryNode", + "AllNodes" + ], + "x-ms-enum": { + "name": "RebootType", + "modelAsString": false + } + }, + "shardId": { + "type": "integer", + "format": "int32", + "description": "In case of cluster cache, this specifies shard id which should be rebooted." + } + }, + "required": [ + "rebootType" + ], + "description": "Specifies which redis node(s) to reboot." + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Client Api Version." + } + } +} \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs new file mode 100644 index 000000000000..e19bd34e90a5 --- /dev/null +++ b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Linq; +using System.Net; +using Microsoft.Rest.Generator; +using Microsoft.Rest.Generator.ClientModel; +using Microsoft.Rest.Generator.CSharp; +using Microsoft.Rest.Generator.Extensibility; +using Microsoft.Rest.Generator.Utilities; +using Xunit; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Rest.Modeler.Swagger.Tests +{ + [Collection("AutoRest Tests")] + public class SwaggerModelerRedisTests + { + [Fact] + public void RedisResponseWithAccessKeys_IsAssignableTo_RedisResponse() + { + Generator.Modeler modeler = new SwaggerModeler(new Settings + { + Namespace = "Test", + Input = Path.Combine("Swagger", "swagger-redis-sample.json") + }); + var clientModel = modeler.Build(); + var redisResponseModel = clientModel.ModelTypes.Single(x => x.Name == "RedisResource"); + var redisResponseWithAccessKeyModel = clientModel.ModelTypes.Single(x => x.Name == "RedisResourceWithAccessKey"); + Assert.Equal(redisResponseModel, redisResponseWithAccessKeyModel.BaseModelType); + } + } +} \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger/SchemaResolver.cs b/AutoRest/Modelers/Swagger/SchemaResolver.cs index 092a8c145f6d..6fbf3603c69e 100644 --- a/AutoRest/Modelers/Swagger/SchemaResolver.cs +++ b/AutoRest/Modelers/Swagger/SchemaResolver.cs @@ -18,7 +18,6 @@ public class SchemaResolver : ICloneable private const int MaximumReferenceDepth = 40; private readonly SwaggerModeler _modeler; private readonly ServiceDefinition _serviceDefinition; - private readonly List _visitedReferences; /// /// Create a new schema resolver in the context of the given swagger spec @@ -33,7 +32,6 @@ public SchemaResolver(SwaggerModeler modeler) _modeler = modeler; _serviceDefinition = modeler.ServiceDefinition; - _visitedReferences = new List(); } /// @@ -44,11 +42,6 @@ public SchemaResolver(SwaggerModeler modeler) public object Clone() { var resolver = new SchemaResolver(_modeler); - foreach (string reference in _visitedReferences) - { - resolver._visitedReferences.Add(reference); - } - return resolver; } @@ -201,12 +194,32 @@ public void ExpandAllOf(Schema schema) if ((parentProperty.Type == null || parentProperty.Type == DataType.Object) && (unwrappedProperty.Type == null || unwrappedProperty.Type == DataType.Object)) { - if (!string.IsNullOrEmpty(parentProperty.Reference) || - !string.IsNullOrEmpty(unwrappedProperty.Reference)) + var parentPropertyToCompare = parentProperty; + var unwrappedPropertyToCompare = unwrappedProperty; + if (!string.IsNullOrEmpty(parentProperty.Reference)) + { + parentPropertyToCompare = Dereference(parentProperty.Reference); + } + if (!string.IsNullOrEmpty(unwrappedProperty.Reference)) { - return parentProperty.Reference == unwrappedProperty.Reference; + unwrappedPropertyToCompare = Dereference(unwrappedProperty.Reference); } - // do not compare inline schemas + + if (parentPropertyToCompare == unwrappedPropertyToCompare) + { + return true; // when fully dereferenced, they can refer to the same thing + } + + // or they can refer to different things... but there can be an inheritance relation... + while (unwrappedPropertyToCompare != null && unwrappedPropertyToCompare.Extends != null) + { + unwrappedPropertyToCompare = Dereference(unwrappedPropertyToCompare.Extends); + if (unwrappedPropertyToCompare == parentPropertyToCompare) + { + return true; + } + } + return false; } if (parentProperty.Type == DataType.Array && @@ -252,6 +265,12 @@ private Schema FindParentProperty(string parentReference, string propertyName) /// The schema reference to dereference. /// The dereferenced schema. private Schema Dereference(string referencePath) + { + var vistedReferences = new List(); + return DereferenceInner(referencePath, vistedReferences); + } + + private Schema DereferenceInner(string referencePath, List visitedReferences) { // Check if external reference string[] splitReference = referencePath.Split(new[] {'#'}, StringSplitOptions.RemoveEmptyEntries); @@ -260,17 +279,17 @@ private Schema Dereference(string referencePath) referencePath = "#" + splitReference[1]; } - if (_visitedReferences.Contains(referencePath.ToLower(CultureInfo.InvariantCulture))) + if (visitedReferences.Contains(referencePath.ToLower(CultureInfo.InvariantCulture))) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.CircularReference, referencePath)); } - if (_visitedReferences.Count >= MaximumReferenceDepth) + if (visitedReferences.Count >= MaximumReferenceDepth) { throw new ArgumentException(Properties.Resources.ExceededMaximumReferenceDepth, referencePath); } - _visitedReferences.Add(referencePath.ToLower(CultureInfo.InvariantCulture)); + visitedReferences.Add(referencePath.ToLower(CultureInfo.InvariantCulture)); var definitions = _serviceDefinition.Definitions; if (definitions == null || !definitions.ContainsKey(referencePath.StripDefinitionPath())) { @@ -282,7 +301,7 @@ private Schema Dereference(string referencePath) var schema = _serviceDefinition.Definitions[referencePath.StripDefinitionPath()]; if (schema.Reference != null) { - schema = Dereference(schema.Reference); + schema = DereferenceInner(schema.Reference, visitedReferences); } return schema; From 5f974470281be5a91231c8c5571462df829174d1 Mon Sep 17 00:00:00 2001 From: TimLovellSmith Date: Mon, 23 May 2016 11:01:27 -0700 Subject: [PATCH 09/23] Modify the circular detection logic for circular 'allOf' inheritance so that there can again be a passing test 'ClientModelWithCircularDependencyThrowsError'. --- .../Swagger.Tests/SwaggerModelerTests.cs | 4 ++- .../Swagger/Properties/Resources.Designer.cs | 9 ++++++ .../Swagger/Properties/Resources.resx | 3 ++ AutoRest/Modelers/Swagger/SchemaResolver.cs | 31 +++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs index 0aac57a71e45..8c7af5c95220 100644 --- a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs +++ b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs @@ -185,7 +185,9 @@ public void ClientModelWithCircularDependencyThrowsError() Namespace = "Test", Input = Path.Combine("Swagger", "swagger-allOf-circular.json") }); - Assert.Throws(() => modeler.Build()); + var ex = Assert.Throws(() => modeler.Build()); + Assert.Contains("circular", ex.Message, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("siamese", ex.Message, StringComparison.InvariantCultureIgnoreCase); } [Fact] diff --git a/AutoRest/Modelers/Swagger/Properties/Resources.Designer.cs b/AutoRest/Modelers/Swagger/Properties/Resources.Designer.cs index e2335bc14a76..bb600eb0be9a 100644 --- a/AutoRest/Modelers/Swagger/Properties/Resources.Designer.cs +++ b/AutoRest/Modelers/Swagger/Properties/Resources.Designer.cs @@ -60,6 +60,15 @@ internal class Resources { } } + /// + /// Looks up a localized string similar to Found a type set '{0}' which is circularly defined.. + /// + internal static string CircularBaseSchemaSet { + get { + return ResourceManager.GetString("CircularBaseSchemaSet", resourceCulture); + } + } + /// /// Looks up a localized string similar to Circular reference detected: {0}. /// diff --git a/AutoRest/Modelers/Swagger/Properties/Resources.resx b/AutoRest/Modelers/Swagger/Properties/Resources.resx index 057ff414a1b2..18588c769584 100644 --- a/AutoRest/Modelers/Swagger/Properties/Resources.resx +++ b/AutoRest/Modelers/Swagger/Properties/Resources.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Found a type set '{0}' which is circularly defined. + Circular reference detected: {0} diff --git a/AutoRest/Modelers/Swagger/SchemaResolver.cs b/AutoRest/Modelers/Swagger/SchemaResolver.cs index 6fbf3603c69e..562b51e737d1 100644 --- a/AutoRest/Modelers/Swagger/SchemaResolver.cs +++ b/AutoRest/Modelers/Swagger/SchemaResolver.cs @@ -82,7 +82,9 @@ public void ExpandAllOf(Schema schema) if (schema.AllOf != null) { + CheckCircularAllOf(schema, null, null); var references = schema.AllOf.Where(s => s.Reference != null).ToList(); + if (references.Count == 1) { if (schema.Extends != null) @@ -101,6 +103,7 @@ public void ExpandAllOf(Schema schema) Properties = schema.Properties }; + var schemaList = new List().Concat(schema.AllOf) .Concat(new List {propertiesOnlySchema}); @@ -170,6 +173,34 @@ public void ExpandAllOf(Schema schema) } } + void CheckCircularAllOf(Schema schema, HashSet visited, Stack referenceChain) + { + visited = visited ?? new HashSet(); + referenceChain = referenceChain ?? new Stack(); + if (!visited.Add(schema)) // was already present in the set + { + var setDescription = "(" + String.Join(", ", referenceChain) + ")"; + throw new InvalidOperationException( + string.Format(CultureInfo.InvariantCulture, + Properties.Resources.CircularBaseSchemaSet, setDescription)); + } + + if (schema.AllOf != null) + { + foreach (var reference in schema.AllOf.Select(s => s.Reference).Where(r => r != null)) + { + referenceChain.Push(reference); + + var deref = Dereference(reference); + CheckCircularAllOf(deref, visited, referenceChain); + + Debug.Assert(reference == referenceChain.Peek()); + referenceChain.Pop(); + } + } + visited.Remove(schema); + } + /// /// Determine equivalence between the types described by two schemas. /// Limit the comparison to exclude comparison of complexe inline schemas. From 2707593a16e43c22af12afcaf50a8ead0c80f0bb Mon Sep 17 00:00:00 2001 From: TimLovellSmith Date: Tue, 24 May 2016 13:48:17 -0700 Subject: [PATCH 10/23] Fix code analysis warnings from using ToLower(CultureInfo.InvariantCulture). --- AutoRest/Modelers/Swagger/SchemaResolver.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AutoRest/Modelers/Swagger/SchemaResolver.cs b/AutoRest/Modelers/Swagger/SchemaResolver.cs index 562b51e737d1..7504d3314106 100644 --- a/AutoRest/Modelers/Swagger/SchemaResolver.cs +++ b/AutoRest/Modelers/Swagger/SchemaResolver.cs @@ -310,7 +310,7 @@ private Schema DereferenceInner(string referencePath, List visitedRefere referencePath = "#" + splitReference[1]; } - if (visitedReferences.Contains(referencePath.ToLower(CultureInfo.InvariantCulture))) + if (visitedReferences.Contains(referencePath.ToUpperInvariant())) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.CircularReference, referencePath)); @@ -320,7 +320,7 @@ private Schema DereferenceInner(string referencePath, List visitedRefere { throw new ArgumentException(Properties.Resources.ExceededMaximumReferenceDepth, referencePath); } - visitedReferences.Add(referencePath.ToLower(CultureInfo.InvariantCulture)); + visitedReferences.Add(referencePath.ToUpperInvariant()); var definitions = _serviceDefinition.Definitions; if (definitions == null || !definitions.ContainsKey(referencePath.StripDefinitionPath())) { From d5a44b0f31817053f2ac40df146554739ca8fcb7 Mon Sep 17 00:00:00 2001 From: Daniel Anvar Date: Tue, 24 May 2016 15:09:01 -0700 Subject: [PATCH 11/23] Adding x-ms-client-flatten parameter to the swagger scehma, as it was missing: the spec defines that it is possible to add that extension to a body parameter. --- schema/swagger-extensions.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schema/swagger-extensions.json b/schema/swagger-extensions.json index 6e6476c56dbf..d2bb3f18b562 100644 --- a/schema/swagger-extensions.json +++ b/schema/swagger-extensions.json @@ -544,6 +544,9 @@ }, "schema": { "$ref": "#/definitions/schema" + }, + "x-ms-client-flatten": { + "$ref": "#/definitions/xmsClientFlatten" } }, "additionalProperties": false From b403b9a006061eec5524734e1fb55511295dfbe8 Mon Sep 17 00:00:00 2001 From: TimLovellSmith Date: Wed, 25 May 2016 12:52:56 -0700 Subject: [PATCH 12/23] Simplify the unit test for verifying redis swagger modelling inheritance scenarios. --- .../AutoRest.Modeler.Swagger.Tests.csproj | 3 +- .../Swagger/swagger-redis-sample.json | 683 ------------------ .../swagger-ref-allOf-inheritance.json | 280 +++++++ .../Swagger.Tests/SwaggerModelerRedisTests.cs | 35 - .../Swagger.Tests/SwaggerModelerTests.cs | 34 + 5 files changed, 315 insertions(+), 720 deletions(-) delete mode 100644 AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json create mode 100644 AutoRest/Modelers/Swagger.Tests/Swagger/swagger-ref-allOf-inheritance.json delete mode 100644 AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs diff --git a/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj b/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj index dda50548a36d..76cdda60224f 100644 --- a/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj +++ b/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj @@ -36,11 +36,10 @@ True Resources.resx - - + PreserveNewest diff --git a/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json b/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json deleted file mode 100644 index bf80d0515b19..000000000000 --- a/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-redis-sample.json +++ /dev/null @@ -1,683 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "RedisManagementClient", - "description": "REST API for Azure Redis Cache Service", - "version": "2016-04-01" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json", - "text/json" - ], - "produces": [ - "application/json", - "text/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { - "put": { - "tags": [ - "Redis" - ], - "operationId": "Redis_CreateOrUpdate", - "description": "Create a redis cache, or replace (overwrite/recreate, with potential downtime) an existing cache", - "parameters": [ - { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group." - }, - { - "name": "name", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the redis cache." - }, - { - "name": "parameters", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/RedisCreateOrUpdateParameters" - }, - "description": "Parameters supplied to the CreateOrUpdate redis operation." - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "201": { - "description": "", - "schema": { - "$ref": "#/definitions/RedisResourceWithAccessKey" - } - }, - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/RedisResourceWithAccessKey" - } - } - } - }, - "delete": { - "tags": [ - "Redis" - ], - "operationId": "Redis_Delete", - "description": "Deletes a redis cache. This operation takes a while to complete.", - "parameters": [ - { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group." - }, - { - "name": "name", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the redis cache." - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "" - }, - "204": { - "description": "" - } - } - }, - "get": { - "tags": [ - "Redis" - ], - "operationId": "Redis_Get", - "description": "Gets a redis cache (resource description).", - "parameters": [ - { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group." - }, - { - "name": "name", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the redis cache." - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/RedisResource" - } - } - } - } - }, - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/": { - "get": { - "tags": [ - "Redis" - ], - "operationId": "Redis_ListByResourceGroup", - "description": "Gets all redis caches in a resource group.", - "parameters": [ - { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group." - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/RedisListResult" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/Redis/": { - "get": { - "tags": [ - "Redis" - ], - "operationId": "Redis_List", - "description": "Gets all redis caches in the specified subscription.", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/RedisListResult" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/listKeys": { - "post": { - "tags": [ - "Redis" - ], - "operationId": "Redis_ListKeys", - "description": "Retrieve a redis cache's access keys. This operation requires write permission to the cache resource.", - "parameters": [ - { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group." - }, - { - "name": "name", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the redis cache." - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "Lists the keys for Redis Cache", - "schema": { - "$ref": "#/definitions/RedisListKeysResult" - } - } - } - } - }, - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/regenerateKey": { - "post": { - "tags": [ - "Redis" - ], - "operationId": "Redis_RegenerateKey", - "description": "Regenerate redis cache's access keys. This operation requires write permission to the cache resource.", - "parameters": [ - { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group." - }, - { - "name": "name", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the redis cache." - }, - { - "name": "parameters", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/RedisRegenerateKeyParameters" - }, - "description": "Specifies which key to reset." - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "Lists the regenerated keys for Redis Cache", - "schema": { - "$ref": "#/definitions/RedisListKeysResult" - } - } - } - } - }, - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/forceReboot": { - "post": { - "tags": [ - "Redis" - ], - "operationId": "Redis_ForceReboot", - "description": "Reboot specified redis node(s). This operation requires write permission to the cache resource. There can be potential data loss.", - "parameters": [ - { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group." - }, - { - "name": "name", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the redis cache." - }, - { - "name": "parameters", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/RedisRebootParameters" - }, - "description": "Specifies which redis node(s) to reboot." - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "" - }, - "204": { - "description": "" - } - } - } - } - }, - "definitions": { - "Sku": { - "properties": { - "name": { - "type": "string", - "description": "What type of redis cache to deploy. Valid values: (Basic, Standard, Premium)", - "enum": [ - "Basic", - "Standard", - "Premium" - ], - "x-ms-enum": { - "name": "SkuName", - "modelAsString": true - } - }, - "family": { - "type": "string", - "description": "Which family to use. Valid values: (C, P)", - "enum": [ - "C", - "P" - ], - "x-ms-enum": { - "name": "SkuFamily", - "modelAsString": true - } - }, - "capacity": { - "type": "integer", - "format": "int32", - "description": "What size of redis cache to deploy. Valid values: for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4)" - } - }, - "required": [ - "name", - "family", - "capacity" - ], - "description": "Sku parameters supplied to the create redis operation." - }, - "RedisProperties": { - "properties": { - "redisVersion": { - "type": "string", - "description": "RedisVersion parameter has been deprecated. As such, it is no longer necessary to provide this parameter and any value specified is ignored." - }, - "sku": { - "$ref": "#/definitions/Sku", - "description": "What sku of redis cache to deploy." - }, - "redisConfiguration": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value etc." - }, - "enableNonSslPort": { - "type": "boolean", - "description": "If the value is true, then the non-ssl redis server port (6379) will be enabled." - }, - "tenantSettings": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "tenantSettings" - }, - "shardCount": { - "type": "integer", - "format": "int32", - "description": "The number of shards to be created on a Premium Cluster Cache." - }, - "subnetId": { - "type": "string", - "description": "The full resource ID of a subnet in a virtual network to deploy the redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1" - }, - "staticIP": { - "type": "string", - "description": "Required when deploying a redis cache inside an existing Azure Virtual Network." - } - }, - "required": [ - "sku" - ], - "description": "Parameters supplied to CreateOrUpdate redis operation." - }, - "Resource": { - "properties": { - "id": { - "readOnly": true, - "type": "string", - "description": "Resource Id" - }, - "name": { - "readOnly": true, - "type": "string", - "description": "Resource name" - }, - "type": { - "readOnly": true, - "type": "string", - "description": "Resource type" - }, - "location": { - "type": "string", - "description": "Resource location" - }, - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Resource tags" - } - }, - "required": [ - "location" - ], - "x-ms-azure-resource": true - }, - "RedisCreateOrUpdateParameters": { - "properties": { - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/RedisProperties", - "description": "Redis cache properties." - } - }, - "required": [ - "properties" - ], - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "Parameters supplied to the CreateOrUpdate Redis operation." - }, - "RedisAccessKeys": { - "properties": { - "primaryKey": { - "type": "string", - "description": "The current primary key that clients can use to authenticate with redis cache." - }, - "secondaryKey": { - "type": "string", - "description": "The current secondary key that clients can use to authenticate with redis cache." - } - }, - "description": "Redis cache access keys." - }, - "RedisReadableProperties": { - "properties": { - "provisioningState": { - "type": "string", - "description": "Redis instance provisioning status" - }, - "hostName": { - "type": "string", - "description": "Redis host name" - }, - "port": { - "type": "integer", - "format": "int32", - "description": "Redis non-ssl port" - }, - "sslPort": { - "type": "integer", - "format": "int32", - "description": "Redis ssl port" - } - }, - "allOf": [ - { - "$ref": "#/definitions/RedisProperties" - } - ], - "description": "Parameters describing a redis instance" - }, - "RedisReadablePropertiesWithAccessKey": { - "properties": { - "accessKeys": { - "$ref": "#/definitions/RedisAccessKeys", - "description": "Redis cache access keys." - } - }, - "allOf": [ - { - "$ref": "#/definitions/RedisReadableProperties" - } - ], - "description": "Properties generated only in response to CreateOrUpdate redis operation." - }, - "RedisResourceWithAccessKey": { - "properties": { - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/RedisReadablePropertiesWithAccessKey", - "description": "Redis cache properties" - } - }, - "allOf": [ - { - "$ref": "#/definitions/RedisResource" - } - ], - "description": "A redis item in CreateOrUpdate Operation response." - }, - "RedisResource": { - "properties": { - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/RedisReadableProperties", - "description": "Redis cache properties" - } - }, - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "A single redis item in List or Get Operation." - }, - "RedisListResult": { - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/RedisResource" - }, - "description": "Results of the list operation" - }, - "nextLink": { - "type": "string", - "description": "Link for next set of locations." - } - }, - "description": "The response of list redis operation." - }, - "RedisListKeysResult": { - "properties": { - "primaryKey": { - "type": "string", - "description": "The current primary key that clients can use to authenticate with redis cache." - }, - "secondaryKey": { - "type": "string", - "description": "The current secondary key that clients can use to authenticate with redis cache." - } - }, - "description": "The response of redis list keys operation." - }, - "RedisRegenerateKeyParameters": { - "properties": { - "keyType": { - "type": "string", - "description": "Which redis access key to reset", - "enum": [ - "Primary", - "Secondary" - ], - "x-ms-enum": { - "name": "RedisKeyType", - "modelAsString": false - } - } - }, - "required": [ - "keyType" - ], - "description": "Specifies which redis access keys to reset." - }, - "RedisRebootParameters": { - "properties": { - "rebootType": { - "type": "string", - "description": "Which redis node(s) to reboot. Depending on this value data loss is possible.", - "enum": [ - "PrimaryNode", - "SecondaryNode", - "AllNodes" - ], - "x-ms-enum": { - "name": "RebootType", - "modelAsString": false - } - }, - "shardId": { - "type": "integer", - "format": "int32", - "description": "In case of cluster cache, this specifies shard id which should be rebooted." - } - }, - "required": [ - "rebootType" - ], - "description": "Specifies which redis node(s) to reboot." - } - }, - "parameters": { - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." - }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "Client Api Version." - } - } -} \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-ref-allOf-inheritance.json b/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-ref-allOf-inheritance.json new file mode 100644 index 000000000000..a72247c6fb38 --- /dev/null +++ b/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-ref-allOf-inheritance.json @@ -0,0 +1,280 @@ +{ + "swagger": "2.0", + "info": { + "title": "RedisManagementClient", + "description": "A sample model for testing that swagger references and allOf gets understood by the modeler properly", + "version": "1.0.0" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "securityDefinitions": { }, + "security": [ ], + "tags": [ ], + "paths": { + "providers/Microsoft.Cache/Redis/{name}": { + "put": { + "operationId": "Redis_CreateOrUpdate", + "description": "Create or update a redis cache", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "" + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RedisCreateOrUpdateParameters" + }, + "description": "Parameters supplied to the CreateOrUpdate redis operation." + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/Resource" + } + } + } + } + } + }, + "definitions": { + "Sku": { + "properties": { + "name": { + "type": "string", + "description": "", + "enum": [ + "Basic", + "Standard", + "Premium" + ], + "x-ms-enum": { + "name": "SkuName", + "modelAsString": true + } + }, + "family": { + "type": "string", + "description": "", + "enum": [ + "C", + "P" + ], + "x-ms-enum": { + "name": "SkuFamily", + "modelAsString": true + } + }, + "capacity": { + "type": "integer", + "format": "int32", + "description": "" + } + }, + "required": [ + "name", + "family", + "capacity" + ], + "description": "Sku parameters supplied to the create redis operation." + }, + "RedisProperties": { + "properties": { + "sku": { + "$ref": "#/definitions/Sku", + "description": "" + }, + "redisConfiguration": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "" + }, + "enableNonSslPort": { + "type": "boolean", + "description": "" + }, + "tenantSettings": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "" + }, + "shardCount": { + "type": "integer", + "format": "int32", + "description": "" + }, + "subnetId": { + "type": "string", + "description": "" + }, + "staticIP": { + "type": "string", + "description": "" + } + }, + "required": [ + "sku" + ], + "description": "'RedisProperties' - Parameters supplied to CreateOrUpdate redis operation." + }, + "Resource": { + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id" + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "description": "''Resource' - common resource information", + "required": [ + "location" + ], + "x-ms-azure-resource": true + }, + "RedisCreateOrUpdateParameters": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/RedisProperties", + "description": "'RedisCreateOrUpdateParameters.properties' - Redis cache properties." + } + }, + "required": [ + "properties" + ], + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "'RedisCreateOrUpdateParameters' - Parameters supplied to the CreateOrUpdate Redis operation." + }, + "RedisAccessKeys": { + "properties": { + "primaryKey": { + "type": "string", + "description": "" + }, + "secondaryKey": { + "type": "string", + "description": "" + } + }, + "description": "'RedisAccessKeys' - Redis cache access keys." + }, + "RedisReadableProperties": { + "properties": { + "provisioningState": { + "type": "string", + "description": "provisioning status" + }, + "hostName": { + "type": "string", + "description": "" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "" + }, + "sslPort": { + "type": "integer", + "format": "int32", + "description": "" + } + }, + "allOf": [ + { + "$ref": "#/definitions/RedisProperties" + } + ], + "description": "'RedisReadableProperties' - Parameters describing a redis instance" + }, + "RedisReadablePropertiesWithAccessKey": { + "properties": { + "accessKeys": { + "$ref": "#/definitions/RedisAccessKeys", + "description": "Redis cache access keys." + } + }, + "allOf": [ + { + "$ref": "#/definitions/RedisReadableProperties" + } + ], + "description": "'RedisReadablePropertiesWithAccessKey' - Access Keys in addition to RedisReadableProperties" + }, + "RedisResourceWithAccessKey": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/RedisReadablePropertiesWithAccessKey", + "description": "'RedisResourceWithAccessKey.properties' Redis cache properties" + } + }, + "allOf": [ + { + "$ref": "#/definitions/RedisResource" + } + ], + "description": "'RedisResourceWithAccessKey' - A redis item in CreateOrUpdate Operation response." + }, + "RedisResource": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/RedisReadableProperties", + "description": "'RedisResource.properties' - Redis cache properties" + } + }, + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "'RedisResource' - A redis resource" + } + } +} \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs deleted file mode 100644 index e19bd34e90a5..000000000000 --- a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerRedisTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System; -using System.IO; -using System.Linq; -using System.Net; -using Microsoft.Rest.Generator; -using Microsoft.Rest.Generator.ClientModel; -using Microsoft.Rest.Generator.CSharp; -using Microsoft.Rest.Generator.Extensibility; -using Microsoft.Rest.Generator.Utilities; -using Xunit; -using Newtonsoft.Json.Linq; - -namespace Microsoft.Rest.Modeler.Swagger.Tests -{ - [Collection("AutoRest Tests")] - public class SwaggerModelerRedisTests - { - [Fact] - public void RedisResponseWithAccessKeys_IsAssignableTo_RedisResponse() - { - Generator.Modeler modeler = new SwaggerModeler(new Settings - { - Namespace = "Test", - Input = Path.Combine("Swagger", "swagger-redis-sample.json") - }); - var clientModel = modeler.Build(); - var redisResponseModel = clientModel.ModelTypes.Single(x => x.Name == "RedisResource"); - var redisResponseWithAccessKeyModel = clientModel.ModelTypes.Single(x => x.Name == "RedisResourceWithAccessKey"); - Assert.Equal(redisResponseModel, redisResponseWithAccessKeyModel.BaseModelType); - } - } -} \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs index 8c7af5c95220..42e20619bf07 100644 --- a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs +++ b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs @@ -206,6 +206,40 @@ public void TestClientModelWithRecursiveTypes() Assert.Equal("String", clientModel.ModelTypes.First(m => m.Name == "Product").Properties[0].Type.ToString()); } + [Fact] + public void TestClientModel_AliasedAndInheritedTypes_SuccessfullyResolveIntoBaseModelRelationships() + { + Generator.Modeler modeler = new SwaggerModeler(new Settings + { + Namespace = "Test", + Input = Path.Combine("Swagger", "swagger-ref-allOf-inheritance.json") + }); + var clientModel = modeler.Build(); + + // This model has a few base type relationships which should be observed: + // RedisResource is a Resource + var resourceModel = clientModel.ModelTypes.Single(x => x.Name == "Resource"); + var redisResourceModel = clientModel.ModelTypes.Single(x => x.Name == "RedisResource"); + Assert.Equal(resourceModel, redisResourceModel.BaseModelType); + + // RedisResourceWithAccessKey is a RedisResource + var redisResponseWithAccessKeyModel = clientModel.ModelTypes.Single(x => x.Name == "RedisResourceWithAccessKey"); + Assert.Equal(redisResourceModel, redisResponseWithAccessKeyModel.BaseModelType); + + // RedisCreateOrUpdateParameters is a Resource + var redisCreateUpdateParametersModel = clientModel.ModelTypes.Single(x => x.Name == "RedisCreateOrUpdateParameters"); + Assert.Equal(resourceModel, redisCreateUpdateParametersModel.BaseModelType); + + // RedisReadableProperties is a RedisProperties + var redisPropertiesModel = clientModel.ModelTypes.Single(x => x.Name == "RedisProperties"); + var redisReadablePropertieModel = clientModel.ModelTypes.Single(x => x.Name == "RedisReadableProperties"); + Assert.Equal(redisPropertiesModel, redisReadablePropertieModel.BaseModelType); + + // RedisReadablePropertiesWithAccessKey is a RedisReadableProperties + var redisReadablePropertiesWithAccessKeysModel = clientModel.ModelTypes.Single(x => x.Name == "RedisReadablePropertiesWithAccessKey"); + Assert.Equal(redisReadablePropertieModel, redisReadablePropertiesWithAccessKeysModel.BaseModelType); + } + [Fact] public void TestClientModelWithNoContent() { From 7954a99bb2b07f99284cf407e5e2fad948e3a4b9 Mon Sep 17 00:00:00 2001 From: TimLovellSmith Date: Wed, 25 May 2016 13:22:04 -0700 Subject: [PATCH 13/23] Turn off CA1822 for test projects, warnings about performance of non-static unit test methods are a waste of time! --- .../Azure.CSharp.Tests/GlobalSuppressions.cs | 7 ----- .../CSharp/CSharp.Tests/GlobalSuppressions.cs | 18 ------------- .../GlobalSuppressions.cs | 26 ------------------- .../Extensions.Tests/GlobalSuppressions.cs | 10 ------- .../GlobalSuppressions.cs | 11 +------- .../Swagger.Tests/GlobalSuppressions.cs | 24 ----------------- .../Swagger.Tests/SwaggerModelerTests.cs | 11 ++++---- Tools/TestRules.ruleset | 4 ++- 8 files changed, 9 insertions(+), 102 deletions(-) diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/GlobalSuppressions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/GlobalSuppressions.cs index 725603fb1ce5..113846cb0d13 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/GlobalSuppressions.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/GlobalSuppressions.cs @@ -8,10 +8,6 @@ // "In Suppression File". // You do not need to add suppressions to this file manually. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", -Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.AcceptanceTests.#ResourceFlatteningGenerationTest()", Justification="Non-static test classes allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", -Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.AcceptanceTests.#EnsureStatusCode`1(System.Net.HttpStatusCode,System.Func`1>>)", Justification="Non-static test classes allow fixtures")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.AcceptanceTests.#LroSadPathTests()", Justification="Test code is straighforward")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", @@ -24,10 +20,7 @@ Target = "Fixtures.Azure.AcceptanceTestsLro.Models.SubProduct.#ProvisioningStateValues", Justification="Necessary for read-only properties in serialization types")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.AcceptanceTests.#XmsRequestClientIdTest()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.AcceptanceTests.#AzureODataTests()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.CSharpAzureCodeNamingFrameworkTests.#ConvertsPageResultsToPageTypeTest()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Scope = "type", Target = "Fixtures.Azure.AcceptanceTestsPaging.Models.Page`1")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.PageJsonTest.#TestNullPageDeSerialization()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.PageJsonTest.#TestNextLinkDeSerialization()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Fixtures.Azure.AcceptanceTestsLro.Models.Resource.#Id")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Fixtures.Azure.AcceptanceTestsLro.Models.Resource.#Type")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Fixtures.Azure.AcceptanceTestsLro.Models.Resource.#Name")] diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/GlobalSuppressions.cs b/AutoRest/Generators/CSharp/CSharp.Tests/GlobalSuppressions.cs index dd1260862d26..85ac07db8665 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/GlobalSuppressions.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/GlobalSuppressions.cs @@ -16,23 +16,6 @@ [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1809:AvoidExcessiveLocals", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.AcceptanceTests.#ArrayTests()", Justification = "Fixture values for serialization")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1809:AvoidExcessiveLocals", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.AcceptanceTests.#DictionaryTests()", Justification = "Fixture values for serialization")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1809:AvoidExcessiveLocals", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.AcceptanceTests.#ComplexTests()", Justification = "Fixture values for serialization")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#TypeNormalizationTest()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#TypeNormalizationWithComplexTypesTest()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#VerifyMethodRenaming()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#NameCollisionTestWithoutNamespace()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#NameCollisionTestWithNamespace()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#SequenceWithRenamedComplexType()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.AcceptanceTests.#EnsureStatusCode`1(System.Net.HttpStatusCode,System.Func`1>>)", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.MirrorTests.#CanRoundTripSequences()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.MirrorTests.#CanRoundtripPolymorphicTypes()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.MirrorTests.#CanRoundtripFilledOutNestedTypesWithoutRecursion()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.MirrorTests.#CanRoundtripFilledOutNestedTypesWithoutRecursion2()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.ProcessOutputListener.#ScrubAndWriteValue(System.String,System.String)", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.MirrorTests.#CanSerializeAndDeserializePrimitiveTypes()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.MirrorTests.#UrlIsCorrectWhenBaseUriContainsSegment()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#VerifyInputMappingsForFlattening()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#VerifyInputMappingsForGrouping()", Justification = "Test classes must be non-static to allow fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.CSharpCodeNamingFrameworkTests.#VerifyInputMappingsForResources()", Justification = "Test classes must be non-static to allow fixtures")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Fixtures.AcceptanceTestsRequiredOptional.Models.ArrayWrapper.#Validate()", Justification="Validation exceptions types are being changed")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Fixtures.AcceptanceTestsRequiredOptional.Models.ClassWrapper.#Validate()", Justification="Validation exceptions types are being changed")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Fixtures.MirrorSequences.Models.ErrorModel.#Validate()", Justification="Validation exceptions types are being changed")] @@ -50,4 +33,3 @@ [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "npm", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.ServiceController.#StartServiceProcess()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Scope = "member", Target = "Fixtures.AcceptanceTestsUrl.AutoRestUrlTestService.#.ctor(System.String,System.Net.Http.DelegatingHandler[])", Justification = "Invalid in the current context.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1809:AvoidExcessiveLocals", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.AcceptanceTests.#TestDictionaryPrimitiveTypes(Fixtures.AcceptanceTestsBodyDictionary.AutoRestSwaggerBATdictionaryService)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Tests.AcceptanceTests.#EnsureStatusCode`2(System.Net.HttpStatusCode,System.Func`1>>)")] diff --git a/AutoRest/Generators/Extensions/Azure.Extensions.Tests/GlobalSuppressions.cs b/AutoRest/Generators/Extensions/Azure.Extensions.Tests/GlobalSuppressions.cs index 314fda5322cc..91b9c621e2bc 100644 --- a/AutoRest/Generators/Extensions/Azure.Extensions.Tests/GlobalSuppressions.cs +++ b/AutoRest/Generators/Extensions/Azure.Extensions.Tests/GlobalSuppressions.cs @@ -8,31 +8,5 @@ // "In Suppression File". // You do not need to add suppressions to this file manually. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#ResourceIsFlattenedForSimpleResource()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#ResourceIsFlattenedForComplexResource()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#SwaggerODataSpecParsingTest()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#SwaggerResourceExternalFalseTest()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#AzureParameterTest()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#PageableTest()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#ExternalResourceTypeIsNullSafe()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", - Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#ResourceIsFlattenedForConflictingResource()", - Justification = "Test methods must not be static to allow suite-level fixtures")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Azure.Extensions.Tests.AzureServiceClientNormalizerTests.#FlatteningTest()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.CSharpAzureCodeNamingFrameworkTests.#ConvertsPageResultsToPageTypeTest()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.Azure.Tests.CSharpAzureCodeNamingFrameworkTests.#ConvertsPageResultsToPageTypeTest()")] diff --git a/AutoRest/Generators/Extensions/Extensions.Tests/GlobalSuppressions.cs b/AutoRest/Generators/Extensions/Extensions.Tests/GlobalSuppressions.cs index a628d38cbf3b..46ddf026866e 100644 --- a/AutoRest/Generators/Extensions/Extensions.Tests/GlobalSuppressions.cs +++ b/AutoRest/Generators/Extensions/Extensions.Tests/GlobalSuppressions.cs @@ -1,14 +1,4 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientModelWithPayloadFlattening()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.MappingExtensionsTests.#TestInputMapping()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientModelWithPayloadFlatteningViaXMSClientFlatten()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientModelWithPayloadFlatteningViaXMSClientFlatten()")] - -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientModelClientName()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientNameCSharpNormalization()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientNameJavaNormalization()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientNameNodeJSNormalization()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientNamePythonNormalization()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Generator.Tests.ExtensionsTests.#TestClientNameRubyNormalization()")] diff --git a/AutoRest/Modelers/CompositeSwagger.Tests/GlobalSuppressions.cs b/AutoRest/Modelers/CompositeSwagger.Tests/GlobalSuppressions.cs index fbc8ea7cbdbc..5f282702bb03 100644 --- a/AutoRest/Modelers/CompositeSwagger.Tests/GlobalSuppressions.cs +++ b/AutoRest/Modelers/CompositeSwagger.Tests/GlobalSuppressions.cs @@ -1,10 +1 @@ -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeSwaggerWithTwoModels()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeSwaggerWithOneModel()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeModelWithEmptyInfo()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeModelWithEmptyDocuments()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeModelWithConflictInSettings()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeModelWithConflictInModel()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeModelWithConflictInMethod()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeModelWithConflictInGlobalParam()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.CompositeSwagger.Tests.CompositeSwaggerModelerTests.#CompositeSwaggerWithSameModels()")] - + \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger.Tests/GlobalSuppressions.cs b/AutoRest/Modelers/Swagger.Tests/GlobalSuppressions.cs index 003d12bb4dc1..d7540fb6b412 100644 --- a/AutoRest/Modelers/Swagger.Tests/GlobalSuppressions.cs +++ b/AutoRest/Modelers/Swagger.Tests/GlobalSuppressions.cs @@ -11,28 +11,4 @@ [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerSpecHelper.#RunTests`1(System.String,System.String,System.String,Microsoft.Rest.Generator.Settings)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerSpecHelper.#RunTests`1(Microsoft.Rest.Generator.Settings,System.String)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestDataTypes()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelFromSimpleSwagger()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestExternalReferences()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestExternalReferencesWithAllOf()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestExternalReferencesWithReferencesInProperties()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestExternalReferencesWithExtension()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithInheritance()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelPolymorhism()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#ClientModelWithCircularDependencyThrowsError()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithRecursiveTypes()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithNoContent()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithDifferentReturnsTypesBasedOnStatusCode()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#DefaultReturnsCorrectType()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#GlobalResponsesReference()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithStreamAndByteArray()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithMethodGroups()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestDataTypes()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientWithValidation()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithPayloadFlattening()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestClientModelWithResponseHeaders()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestCustomPaths()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestSettingsFromSwagger()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "client", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestSettingsFromSwagger()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestConstants()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Rest.Modeler.Swagger.Tests.SwaggerModelerTests.#TestCompositeConstants()")] - diff --git a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs index 42e20619bf07..6083741a77c6 100644 --- a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs +++ b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs @@ -186,8 +186,8 @@ public void ClientModelWithCircularDependencyThrowsError() Input = Path.Combine("Swagger", "swagger-allOf-circular.json") }); var ex = Assert.Throws(() => modeler.Build()); - Assert.Contains("circular", ex.Message, StringComparison.InvariantCultureIgnoreCase); - Assert.Contains("siamese", ex.Message, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("circular", ex.Message, StringComparison.OrdinalIgnoreCase); + Assert.Contains("siamese", ex.Message, StringComparison.OrdinalIgnoreCase); } [Fact] @@ -207,16 +207,16 @@ public void TestClientModelWithRecursiveTypes() } [Fact] - public void TestClientModel_AliasedAndInheritedTypes_SuccessfullyResolveIntoBaseModelRelationships() + public void TestClientModelWithManyAllOfRelationships() { - Generator.Modeler modeler = new SwaggerModeler(new Settings + var modeler = new SwaggerModeler(new Settings { Namespace = "Test", Input = Path.Combine("Swagger", "swagger-ref-allOf-inheritance.json") }); var clientModel = modeler.Build(); - // This model has a few base type relationships which should be observed: + // the model has a few base type relationships which should be observed: // RedisResource is a Resource var resourceModel = clientModel.ModelTypes.Single(x => x.Name == "Resource"); var redisResourceModel = clientModel.ModelTypes.Single(x => x.Name == "RedisResource"); @@ -596,7 +596,6 @@ public void TestSettingsFromSwagger() Assert.Equal(true, codeGenerator.InternalConstructors); } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] [Fact] public void TestParameterizedHostFromSwagger() { diff --git a/Tools/TestRules.ruleset b/Tools/TestRules.ruleset index 6c0755dd13d5..15f831c090a8 100644 --- a/Tools/TestRules.ruleset +++ b/Tools/TestRules.ruleset @@ -1,4 +1,4 @@ - + @@ -35,6 +35,8 @@ + + From 9f4f7d6a2fe574ecc754ac69446672c293416b52 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Wed, 25 May 2016 15:09:31 -0700 Subject: [PATCH 14/23] Bumped up gulp npm versions --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a9b3cfe977a2..2a299581d80b 100644 --- a/package.json +++ b/package.json @@ -22,15 +22,15 @@ "devDependencies": { "del": "^1.2.0", "glob": "^5.0.13", - "gulp": "^3.9.0", - "gulp-debug": "^2.0.1", + "gulp": "^3.9.1", + "gulp-debug": "^2.1.2", "gulp-dotnet-assembly-info": "^0.1.10", - "gulp-env": "^0.2.0", - "gulp-msbuild": "^0.2.13", + "gulp-env": "^0.4.0", + "gulp-msbuild": "^0.3.2", "gulp-replace": "^0.5.3", - "gulp-shell": "^0.5", + "gulp-shell": "^0.5.2", "gulp-spawn": "^0.3.0", - "gulp-util": "^3", + "gulp-util": "^3.0.7", "merge2": "^0.3.6", "q": "^1.4.1", "require-dir": "^0.3.0", From 58366bddf17bb46bb80788f91877b17729a58425 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Wed, 25 May 2016 16:01:32 -0700 Subject: [PATCH 15/23] Adding more logging for gulp.msbuild and retrying for http failures. --- .../CSharp/CSharp.Tests/AcceptanceTests.cs | 23 +++++++++++++++++-- gulpfile.js | 4 +++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs b/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs index f4d91ea4bf75..a2d0b461e740 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs @@ -2310,8 +2310,27 @@ private static void EnsureStatusCode(HttpStatusCode expectedStatusCode, Func(HttpStatusCode expectedStatusCode, Func>> operation) { - var response = operation().GetAwaiter().GetResult(); - Assert.Equal(response.Response.StatusCode, expectedStatusCode); + // Adding retry because of flakiness of TestServer on Travis runs + HttpRequestException ex = null; + for (int i = 0; i < 3; i++) + { + HttpOperationHeaderResponse response; + try + { + response = operation().GetAwaiter().GetResult(); + } + catch(HttpRequestException x) + { + System.Threading.Thread.Sleep(10); + ex = x; + continue; + } + Assert.Equal(response.Response.StatusCode, expectedStatusCode); + return; + } + Assert.True( + false, + string.Format("EnsureStatusCode for '{0}' failed 3 times in a row. Last failure message: {1}", expectedStatusCode, ex)); } private static void EnsureThrowsWithStatusCode(HttpStatusCode expectedStatusCode, diff --git a/gulpfile.js b/gulpfile.js index cdff66a8442e..85ef29e5d12d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -498,7 +498,9 @@ gulp.task('build', function(cb) { // warning 0219 is for unused variables, which causes the build to fail on xbuild return gulp.src('build.proj').pipe(msbuild(mergeOptions(msbuildDefaults, { targets: ['build'], - properties: { WarningsNotAsErrors: 0219, Configuration: 'Debug' } + properties: { WarningsNotAsErrors: 0219, Configuration: 'Debug' }, + stdout: true, + errorOnFail: true }))); }); From 22f7fc7a9291f6860907242ccdb93d33adb353e1 Mon Sep 17 00:00:00 2001 From: Thomas Bombach Date: Wed, 25 May 2016 16:30:51 -0700 Subject: [PATCH 16/23] Cleaning up typos and comments for ServiceClient SetUserAgent --- .../ServiceClient.cs | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index bba5be03f8a2..d33ab3bdeef9 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -210,48 +210,48 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, GetClientVersion())); } - /// - ///A mehtod to set user agent - /// + + /// + /// Sets the product name to be used in the user agent header when making requests + /// + /// Name of the product to be used in the user agent public bool SetUserAgent(string productName) { - if(!_disposed && HttpClient != null) + if (!_disposed && HttpClient != null) { - /// - /// Dispose the the old useragent. - /// + // Clear the old user agent HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, GetClientVersion())); - // returns true if the userAgent was added + + // Returns true if the user agent was set return true; } - /// - ///returns false if the httpclient was disposed before invoking the method - /// + + // Returns false if the HttpClient was disposed before invoking the method return false; } - /// - ///Another method to setuseragent and its version - /// - public bool SetUserAgent(string productName,string version) + + /// + /// Sets the product name and version to be used in the user agent header when making requests + /// + /// Name of the product to be used in the user agent + /// Version of the product to be used in the user agent + public bool SetUserAgent(string productName, string version) { - if(!_disposed && HttpClient != null) + if (!_disposed && HttpClient != null) { - /// - /// Dispose the the old useragent. - /// + // Clear the old user agent HttpClient.DefaultRequestHeaders.UserAgent.Clear(); - HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version)); - /// - // returns true if the userAgent was added - /// + HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, version)); + + // Returns true if the user agent was set return true; } - /// - /// returns false if the httpclient was disposed before invoking the method - /// + + // Returns false if the HttpClient was disposed before invoking the method return false; } + /// /// Gets the AssemblyInformationalVersion if available /// if not it gets the AssemblyFileVerion From f233c04a857d811e8039e036e5068aa2e11b11b1 Mon Sep 17 00:00:00 2001 From: Garrett Serack Date: Thu, 26 May 2016 11:40:11 -0700 Subject: [PATCH 17/23] Adding YAML support to Autorest. --- AutoRest/AutoRest.Core/AutoRest.nuspec | 1 + .../AcceptanceTests.cs | 7 + ...Generator.AzureResourceSchema.Tests.csproj | 3 + .../Swagger/web.yaml | 15193 ++++++++++++++++ .../AutoRest.Modeler.Swagger.Tests.csproj | 5 +- .../Swagger/swagger-simple-spec.yaml | 128 + .../Swagger.Tests/SwaggerModelerTests.cs | 13 + .../Swagger/AutoRest.Modeler.Swagger.csproj | 7 + AutoRest/Modelers/Swagger/Extensions.cs | 22 + AutoRest/Modelers/Swagger/SwaggerParser.cs | 1 + .../Modelers/Swagger/YamlBoolDeserializer.cs | 51 + AutoRest/Modelers/Swagger/packages.config | 1 + Tools/CustomDictionary.xml | 2 + Tools/references.net45.props | 3 + build.proj | 2 +- 15 files changed, 15437 insertions(+), 2 deletions(-) create mode 100644 AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/web.yaml create mode 100644 AutoRest/Modelers/Swagger.Tests/Swagger/swagger-simple-spec.yaml create mode 100644 AutoRest/Modelers/Swagger/YamlBoolDeserializer.cs diff --git a/AutoRest/AutoRest.Core/AutoRest.nuspec b/AutoRest/AutoRest.Core/AutoRest.nuspec index 2af544a88582..e201f91aebd6 100644 --- a/AutoRest/AutoRest.Core/AutoRest.nuspec +++ b/AutoRest/AutoRest.Core/AutoRest.nuspec @@ -35,5 +35,6 @@ + diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AcceptanceTests.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AcceptanceTests.cs index 97cbab6189e3..a04abe5c0610 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AcceptanceTests.cs @@ -47,6 +47,13 @@ public static void Web() RunSwaggerTest("web.json", "Web"); } + [Fact] + public static void WebYaml() + { + // same test as Web(), but converted to YAML + RunSwaggerTest("web.yaml", "Web"); + } + private static void RunSwaggerTest(string swaggerFileName, string expectedFolderName) { SwaggerSpecHelper.RunTests( diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AutoRest.Generator.AzureResourceSchema.Tests.csproj b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AutoRest.Generator.AzureResourceSchema.Tests.csproj index cd000e238b54..1297ed533000 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AutoRest.Generator.AzureResourceSchema.Tests.csproj +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AutoRest.Generator.AzureResourceSchema.Tests.csproj @@ -123,6 +123,9 @@ PreserveNewest + + PreserveNewest + diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/web.yaml b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/web.yaml new file mode 100644 index 000000000000..41cf16380b24 --- /dev/null +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/web.yaml @@ -0,0 +1,15193 @@ +swagger: '2.0' +info: + version: '2015-08-01' + title: WebSite Management Client + description: >- + Use these APIs to manage Azure Websites resources through the Azure Resource + Manager. All task operations conform to the HTTP/1.1 protocol specification + and each operation returns an x-ms-request-id header that can be used to + obtain information about the request. You must make sure that requests made + to these resources are secure. For more information, see Authenticating + Azure Resource Manager requests. +host: management.azure.com +schemes: + - https +paths: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates/{name}': + get: + tags: + - CertificateOrders + summary: Get certificate associated with the certificate order + operationId: CertificateOrders_GetCertificate + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: "true" + type: string + - name: certificateOrderName + in: path + description: Certificate name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrderCertificate' + deprecated: false + put: + tags: + - CertificateOrders + summary: >- + Associates a Key Vault secret to a certificate store that will be used + for storing the certificate once it's ready + operationId: CertificateOrders_CreateOrUpdateCertificate + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: certificateOrderName + in: path + description: Certificate name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - name: keyVaultCertificate + in: body + description: Key Vault secret csm Id + required: true + schema: + $ref: '#/definitions/CertificateOrderCertificate' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrderCertificate' + deprecated: false + delete: + tags: + - CertificateOrders + summary: Deletes the certificate associated with the certificate order + operationId: CertificateOrders_DeleteCertificate + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: certificateOrderName + in: path + description: Certificate name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - CertificateOrders + summary: >- + Associates a Key Vault secret to a certificate store that will be used + for storing the certificate once it's ready + operationId: CertificateOrders_UpdateCertificate + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: certificateOrderName + in: path + description: Certificate name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - name: keyVaultCertificate + in: body + description: Key Vault secret csm Id + required: true + schema: + $ref: '#/definitions/CertificateOrderCertificate' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrderCertificate' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}': + get: + tags: + - CertificateOrders + summary: Get a certificate order + operationId: CertificateOrders_GetCertificateOrder + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrder' + deprecated: false + put: + tags: + - CertificateOrders + summary: Create or update a certificate purchase order + operationId: CertificateOrders_CreateOrUpdateCertificateOrder + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - name: certificateDistinguishedName + in: body + description: Distinguished name to be used for purchasing certificate + required: true + schema: + $ref: '#/definitions/CertificateOrder' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrder' + deprecated: false + delete: + tags: + - CertificateOrders + summary: Delete an existing certificate order + operationId: CertificateOrders_DeleteCertificateOrder + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - CertificateOrders + summary: Create or update a certificate purchase order + operationId: CertificateOrders_UpdateCertificateOrder + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - name: certificateDistinguishedName + in: body + description: Distinguished name to be used for purchasing certificate + required: true + schema: + $ref: '#/definitions/CertificateOrder' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrder' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders': + get: + tags: + - CertificateOrders + summary: Get certificate orders in a resource group + operationId: CertificateOrders_GetCertificateOrders + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrderCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates': + get: + tags: + - CertificateOrders + summary: >- + List all certificates associated with a certificate order (only one + certificate can be associated with an order at a time) + operationId: CertificateOrders_GetCertificates + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: certificateOrderName + in: path + description: Certificate name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrderCertificateCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/reissue': + post: + tags: + - CertificateOrders + summary: Reissue an existing certificate order + operationId: CertificateOrders_ReissueCertificateOrder + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - name: reissueCertificateOrderRequest + in: body + description: Reissue parameters + required: true + schema: + $ref: '#/definitions/ReissueCertificateOrderRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/renew': + post: + tags: + - CertificateOrders + summary: Renew an existing certificate order + operationId: CertificateOrders_RenewCertificateOrder + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate name + required: true + type: string + - name: renewCertificateOrderRequest + in: body + description: Renew parameters + required: true + schema: + $ref: '#/definitions/RenewCertificateOrderRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/retrieveCertificateActions': + post: + tags: + - CertificateOrders + summary: Retrieve the list of certificate actions + operationId: CertificateOrders_RetrieveCertificateActions + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate order name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/CertificateOrderAction' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/retrieveEmailHistory': + post: + tags: + - CertificateOrders + summary: Retrive email history + operationId: CertificateOrders_RetrieveCertificateEmailHistory + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate order name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/CertificateEmail' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/resendEmail': + post: + tags: + - CertificateOrders + summary: Resend certificate email + operationId: CertificateOrders_ResendCertificateEmail + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate order name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/verifyDomainOwnership': + post: + tags: + - CertificateOrders + summary: Verify domain ownership for this certificate order + operationId: CertificateOrders_VerifyDomainOwnership + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Azure resource group name + required: true + type: string + - name: name + in: path + description: Certificate order name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates': + get: + tags: + - Certificates + summary: Get certificates for a subscription in the specified resource group. + operationId: Certificates_GetCertificates + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates/{name}': + get: + tags: + - Certificates + summary: >- + Get a certificate by certificate name for a subscription in the + specified resource group. + operationId: Certificates_GetCertificate + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Certificate' + deprecated: false + put: + tags: + - Certificates + summary: Creates or modifies an existing certificate. + operationId: Certificates_CreateOrUpdateCertificate + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate. + required: true + type: string + - name: certificateEnvelope + in: body + description: Details of certificate if it exists already. + required: true + schema: + $ref: '#/definitions/Certificate' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Certificate' + deprecated: false + delete: + tags: + - Certificates + summary: >- + Delete a certificate by name in a specificed subscription and + resourcegroup. + operationId: Certificates_DeleteCertificate + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate to be deleted. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Certificates + summary: Creates or modifies an existing certificate. + operationId: Certificates_UpdateCertificate + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate. + required: true + type: string + - name: certificateEnvelope + in: body + description: Details of certificate if it exists already. + required: true + schema: + $ref: '#/definitions/Certificate' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Certificate' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/csrs': + get: + tags: + - Certificates + summary: >- + Gets the certificate signing requests for a subscription in the + specified resource group + operationId: Certificates_GetCsrs + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/Csr' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/csrs/{name}': + get: + tags: + - Certificates + summary: >- + Gets a certificate signing request by certificate name for a + subscription in the specified resource group + operationId: Certificates_GetCsr + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Csr' + deprecated: false + put: + tags: + - Certificates + summary: Creates or modifies an existing certificate signing request. + operationId: Certificates_CreateOrUpdateCsr + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate. + required: true + type: string + - name: csrEnvelope + in: body + description: Details of certificate signing request if it exists already. + required: true + schema: + $ref: '#/definitions/Csr' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Csr' + deprecated: false + delete: + tags: + - Certificates + summary: Delete the certificate signing request. + operationId: Certificates_DeleteCsr + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate signing request. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Certificates + summary: Creates or modifies an existing certificate signing request. + operationId: Certificates_UpdateCsr + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the certificate. + required: true + type: string + - name: csrEnvelope + in: body + description: Details of certificate signing request if it exists already. + required: true + schema: + $ref: '#/definitions/Csr' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Csr' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/classicMobileServices': + get: + tags: + - ClassicMobileServices + summary: Get all mobile services in a resource group. + operationId: ClassicMobileServices_GetClassicMobileServices + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ClassicMobileServiceCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/classicMobileServices/{name}': + get: + tags: + - ClassicMobileServices + summary: Get a mobile service. + operationId: ClassicMobileServices_GetClassicMobileService + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of mobile service + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ClassicMobileService' + deprecated: false + delete: + tags: + - ClassicMobileServices + summary: Delete a mobile service. + operationId: ClassicMobileServices_DeleteClassicMobileService + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of mobile service + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DomainRegistration/domains': + get: + tags: + - Domains + summary: Lists domains under a resource group + operationId: Domains_GetDomains + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DomainCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DomainRegistration/domains/{domainName}': + get: + tags: + - Domains + summary: Gets details of a domain + operationId: Domains_GetDomain + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: domainName + in: path + description: Name of the domain + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Domain' + deprecated: false + put: + tags: + - Domains + summary: Creates a domain + operationId: Domains_CreateOrUpdateDomain + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: '>Name of the resource group' + required: true + type: string + - name: domainName + in: path + description: Name of the domain + required: true + type: string + - name: domain + in: body + description: Domain registration information + required: true + schema: + $ref: '#/definitions/Domain' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: Domain purchase was successful + schema: + $ref: '#/definitions/Domain' + '202': + description: Domain purchase is in progress + schema: + $ref: '#/definitions/Domain' + deprecated: false + delete: + tags: + - Domains + summary: Deletes a domain + operationId: Domains_DeleteDomain + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: domainName + in: path + description: Name of the domain + required: true + type: string + - name: forceHardDeleteDomain + in: query + description: >- + If true then the domain will be deleted immediately instead of after + 24 hours + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '204': + description: >- + Domain does not exist in Azure database probably because it has + already been deleted + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Domains + summary: Creates a domain + operationId: Domains_UpdateDomain + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: '>Name of the resource group' + required: true + type: string + - name: domainName + in: path + description: Name of the domain + required: true + type: string + - name: domain + in: body + description: Domain registration information + required: true + schema: + $ref: '#/definitions/Domain' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: Domain purchase was successful + schema: + $ref: '#/definitions/Domain' + '202': + description: Domain purchase is in progress + schema: + $ref: '#/definitions/Domain' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DomainRegistration/domains/{domainName}/operationresults/{operationId}': + get: + tags: + - Domains + summary: Retrieves the latest status of a domain purchase operation + operationId: Domains_GetDomainOperation + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: domainName + in: path + description: Name of the domain + required: true + type: string + - name: operationId + in: path + description: Domain purchase operation Id + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: Domain purchase was successful + schema: + $ref: '#/definitions/Domain' + '202': + description: Domain purchase is in progress + schema: + $ref: '#/definitions/Domain' + '500': + description: Domain purchase request failed + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/publishingCredentials': + get: + tags: + - Global + summary: Gets publishing credentials for the subscription owner + operationId: Global_GetSubscriptionPublishingCredentials + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/User' + deprecated: false + put: + tags: + - Global + summary: Updates publishing credentials for the subscription owner + operationId: Global_UpdateSubscriptionPublishingCredentials + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: requestMessage + in: body + description: requestMessage with new publishing credentials + required: true + schema: + $ref: '#/definitions/User' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/User' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/geoRegions': + get: + tags: + - Global + summary: Gets list of available geo regions + operationId: Global_GetSubscriptionGeoRegions + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: sku + in: query + description: Filter only to regions that support this sku + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/GeoRegionCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/certificates': + get: + tags: + - Global + summary: Get all certificates for a subscription + operationId: Global_GetAllCertificates + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/serverfarms': + get: + tags: + - Global + summary: Gets all App Service Plans for a subcription + operationId: Global_GetAllServerFarms + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: detailed + in: query + description: "False to return a subset of App Service Plan properties, true to return all of the properties.\r\n Retrieval of all properties may increase the API latency." + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/sites': + get: + tags: + - Global + summary: Gets all Web Apps for a subscription + operationId: Global_GetAllSites + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/hostingEnvironments': + get: + tags: + - Global + summary: >- + Gets all hostingEnvironments (App Service Environment) for a + subscription + operationId: Global_GetAllHostingEnvironments + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostingEnvironmentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/managedHostingEnvironments': + get: + tags: + - Global + summary: Gets all managed hosting environments for a subscription + operationId: Global_GetAllManagedHostingEnvironments + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ManagedHostingEnvironmentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/classicMobileServices': + get: + tags: + - Global + summary: Gets all mobile services for a subscription + operationId: Global_GetAllClassicMobileServices + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ClassicMobileServiceCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/premieraddonoffers': + get: + tags: + - Global + summary: List premier add on offers + operationId: Global_ListPremierAddOnOffers + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/ishostingenvironmentnameavailable': + get: + tags: + - Global + summary: Whether hosting environment name is available + operationId: Global_IsHostingEnvironmentNameAvailable + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: name + in: query + description: Hosting environment name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/ishostingenvironmentnameavailable/{name}': + get: + tags: + - Global + summary: Whether hosting environment name is available + operationId: Global_IsHostingEnvironmentWithLegacyNameAvailable + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: name + in: path + description: Hosting environment name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/checknameavailability': + post: + tags: + - Global + summary: Check if resource name is available + operationId: Global_CheckNameAvailability + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: request + in: body + description: Name availability request + required: true + schema: + $ref: '#/definitions/ResourceNameAvailabilityRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ResourceNameAvailability' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.CertificateRegistration/certificateOrders': + get: + tags: + - GlobalCertificateOrder + summary: Lists all domains in a subscription + operationId: GlobalCertificateOrder_GetAllCertificateOrders + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CertificateOrderCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation': + post: + tags: + - GlobalCertificateOrder + summary: Validate certificate purchase information + operationId: GlobalCertificateOrder_ValidateCertificatePurchaseInformation + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: certificateOrder + in: body + description: Certificate order + required: true + schema: + $ref: '#/definitions/CertificateOrder' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/domains': + get: + tags: + - GlobalDomainRegistration + summary: Lists all domains in a subscription + operationId: GlobalDomainRegistration_GetAllDomains + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DomainCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/generateSsoRequest': + post: + tags: + - GlobalDomainRegistration + summary: Generates a single sign on request for domain management portal + operationId: GlobalDomainRegistration_GetDomainControlCenterSsoRequest + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DomainControlCenterSsoRequest' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/validateDomainRegistrationInformation': + post: + tags: + - GlobalDomainRegistration + summary: Validates domain registration information + operationId: GlobalDomainRegistration_ValidateDomainPurchaseInformation + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: domainRegistrationInput + in: body + description: Domain registration information + required: true + schema: + $ref: '#/definitions/DomainRegistrationInput' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/checkDomainAvailability': + post: + tags: + - GlobalDomainRegistration + summary: Checks if a domain is available for registration + operationId: GlobalDomainRegistration_CheckDomainAvailability + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: identifier + in: body + description: Name of the domain + required: true + schema: + $ref: '#/definitions/NameIdentifier' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DomainAvailablilityCheckResult' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/listDomainRecommendations': + post: + tags: + - GlobalDomainRegistration + summary: Lists domain recommendations based on keywords + operationId: GlobalDomainRegistration_ListDomainRecommendations + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + parameters: + - name: parameters + in: body + description: Domain recommendation search parameters + required: true + schema: + $ref: '#/definitions/DomainRecommendationSearchParameters' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/NameIdentifierCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources': + post: + tags: + - GlobalResourceGroups + operationId: GlobalResourceGroups_MoveResources + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: [] + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: moveResourceEnvelope + in: body + required: true + schema: + $ref: '#/definitions/CsmMoveResourceEnvelope' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '204': + description: No Content + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}': + get: + tags: + - HostingEnvironments + summary: Get properties of hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetHostingEnvironment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostingEnvironment' + deprecated: false + put: + tags: + - HostingEnvironments + summary: Create or update a hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_CreateOrUpdateHostingEnvironment + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: hostingEnvironmentEnvelope + in: body + description: Properties of hostingEnvironment (App Service Environment) + required: true + schema: + $ref: '#/definitions/HostingEnvironment' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostingEnvironment' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/HostingEnvironment' + '400': + description: Bad request + '404': + description: Not found + '409': + description: Conflict + deprecated: false + x-ms-long-running-operation: true + delete: + tags: + - HostingEnvironments + summary: Delete a hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_DeleteHostingEnvironment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: forceDelete + in: query + description: >- + Delete even if the hostingEnvironment (App Service Environment) + contains resources + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/Object' + '400': + description: Bad request + '404': + description: Not found + '409': + description: Conflict + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/diagnostics': + get: + tags: + - HostingEnvironments + summary: >- + Get diagnostic information for hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentDiagnostics + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/HostingEnvironmentDiagnostics' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/diagnostics/{diagnosticsName}': + get: + tags: + - HostingEnvironments + summary: >- + Get diagnostic information for hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentDiagnosticsItem + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: diagnosticsName + in: path + description: Name of the diagnostics + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostingEnvironmentDiagnostics' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/capacities/compute': + get: + tags: + - HostingEnvironments + summary: >- + Get used, available, and total worker capacity for hostingEnvironment + (App Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentCapacities + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StampCapacityCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/capacities/virtualip': + get: + tags: + - HostingEnvironments + summary: >- + Get IP addresses assigned to the hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentVips + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/AddressResponse' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments': + get: + tags: + - HostingEnvironments + summary: >- + Get all hostingEnvironments (App Service Environments) in a resource + group. + operationId: HostingEnvironments_GetHostingEnvironments + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostingEnvironmentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/reboot': + post: + tags: + - HostingEnvironments + summary: Reboots all machines in a hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_RebootHostingEnvironment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Object' + '400': + description: Bad request + '404': + description: Not found + '409': + description: Conflict + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/operations': + get: + tags: + - HostingEnvironments + summary: >- + List all currently running operations on the hostingEnvironment (App + Service Environment) + operationId: HostingEnvironments_GetHostingEnvironmentOperations + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/operations/{operationId}': + get: + tags: + - HostingEnvironments + summary: >- + Get status of an operation on a hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentOperation + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: operationId + in: path + description: operation identifier GUID + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: Operation completed successfully + schema: + $ref: '#/definitions/Object' + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Object' + '404': + description: Not found + '500': + description: Operation failed + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/metrics': + get: + tags: + - HostingEnvironments + summary: Get global metrics of hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentMetrics + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: details + in: query + description: Include instance details + type: boolean + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ResourceMetricCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/metricdefinitions': + get: + tags: + - HostingEnvironments + summary: >- + Get global metric definitions of hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentMetricDefinitions + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/MetricDefinition' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/usages': + get: + tags: + - HostingEnvironments + summary: Get global usages of hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentUsages + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CsmUsageQuotaCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools/default/metrics': + get: + tags: + - HostingEnvironments + summary: >- + Get metrics for a multiRole pool of a hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentMultiRoleMetrics + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: startTime + in: query + description: Beginning time of metrics query + type: string + - name: endTime + in: query + description: End time of metrics query + type: string + - name: timeGrain + in: query + description: Time granularity of metrics query + type: string + - name: details + in: query + description: Include instance details + type: boolean + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ResourceMetricCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools/{workerPoolName}/metrics': + get: + tags: + - HostingEnvironments + summary: >- + Get metrics for a worker pool of a hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentWebWorkerMetrics + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - name: details + in: query + description: Include instance details + type: boolean + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ResourceMetricCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools/default/metricdefinitions': + get: + tags: + - HostingEnvironments + summary: >- + Get metric definitions for a multiRole pool of a hostingEnvironment (App + Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentMultiRoleMetricDefinitions + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/MetricDefinitionCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools/{workerPoolName}/metricdefinitions': + get: + tags: + - HostingEnvironments + summary: >- + Get metric definitions for a worker pool of a hostingEnvironment (App + Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentWebWorkerMetricDefinitions + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/MetricDefinitionCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools/default/usages': + get: + tags: + - HostingEnvironments + summary: >- + Get usages for a multiRole pool of a hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentMultiRoleUsages + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/UsageCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools/{workerPoolName}/usages': + get: + tags: + - HostingEnvironments + summary: >- + Get usages for a worker pool of a hostingEnvironment (App Service + Environment). + operationId: HostingEnvironments_GetHostingEnvironmentWebWorkerUsages + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/UsageCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/sites': + get: + tags: + - HostingEnvironments + summary: Get all sites on the hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentSites + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: propertiesToInclude + in: query + description: Comma separated list of site properties to include + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/webhostingplans': + get: + tags: + - HostingEnvironments + summary: >- + Get all serverfarms (App Service Plans) on the hostingEnvironment (App + Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentWebHostingPlans + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/serverfarms': + get: + tags: + - HostingEnvironments + summary: >- + Get all serverfarms (App Service Plans) on the hostingEnvironment (App + Service Environment). + operationId: HostingEnvironments_GetHostingEnvironmentServerFarms + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools': + get: + tags: + - HostingEnvironments + summary: Get all multi role pools + operationId: HostingEnvironments_GetMultiRolePools + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/WorkerPoolCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools/default': + get: + tags: + - HostingEnvironments + summary: Get properties of a multiRool pool. + operationId: HostingEnvironments_GetMultiRolePool + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/WorkerPool' + deprecated: false + put: + tags: + - HostingEnvironments + summary: Create or update a multiRole pool. + operationId: HostingEnvironments_CreateOrUpdateMultiRolePool + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: multiRolePoolEnvelope + in: body + description: Properties of multiRole pool + required: true + schema: + $ref: '#/definitions/WorkerPool' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/WorkerPool' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/WorkerPool' + '400': + description: Bad request + '404': + description: Not found + '409': + description: Conflict + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools/default/skus': + get: + tags: + - HostingEnvironments + summary: Get available skus for scaling a multiRole pool. + operationId: HostingEnvironments_GetMultiRolePoolSkus + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SkuInfoCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools': + get: + tags: + - HostingEnvironments + summary: Get all worker pools + operationId: HostingEnvironments_GetWorkerPools + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/WorkerPoolCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools/{workerPoolName}': + get: + tags: + - HostingEnvironments + summary: Get properties of a worker pool. + operationId: HostingEnvironments_GetWorkerPool + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/WorkerPool' + deprecated: false + put: + tags: + - HostingEnvironments + summary: Create or update a worker pool. + operationId: HostingEnvironments_CreateOrUpdateWorkerPool + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - name: workerPoolEnvelope + in: body + description: Properties of worker pool + required: true + schema: + $ref: '#/definitions/WorkerPool' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/WorkerPool' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/WorkerPool' + '400': + description: Bad request + '404': + description: Not found + '409': + description: Conflict + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools/{workerPoolName}/skus': + get: + tags: + - HostingEnvironments + summary: Get available skus for scaling a worker pool. + operationId: HostingEnvironments_GetWorkerPoolSkus + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SkuInfoCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools/{workerPoolName}/instances/{instance}/metrics': + get: + tags: + - HostingEnvironments + summary: >- + Get metrics for a specific instance of a worker pool of a + hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetWorkerPoolInstanceMetrics + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - name: instance + in: path + description: Name of instance in the worker pool + required: true + type: string + - name: details + in: query + description: Include instance details + type: boolean + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/workerPools/{workerPoolName}/instances/{instance}/metricdefinitions': + get: + tags: + - HostingEnvironments + summary: >- + Get metric definitions for a specific instance of a worker pool of a + hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetWorkerPoolInstanceMetricDefinitions + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: workerPoolName + in: path + description: Name of worker pool + required: true + type: string + - name: instance + in: path + description: Name of instance in the worker pool + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools/default/instances/{instance}/metrics': + get: + tags: + - HostingEnvironments + summary: >- + Get metrics for a specific instance of a multiRole pool of a + hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetMultiRolePoolInstanceMetrics + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: instance + in: path + description: Name of instance in the multiRole pool + required: true + type: string + - name: details + in: query + description: Include instance details + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/multiRolePools/default/instances/{instance}/metricdefinitions': + get: + tags: + - HostingEnvironments + summary: >- + Get metric definitions for a specific instance of a multiRole pool of a + hostingEnvironment (App Service Environment). + operationId: HostingEnvironments_GetMultiRolePoolInstanceMetricDefinitions + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - name: instance + in: path + description: Name of instance in the multiRole pool> + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/suspend': + post: + tags: + - HostingEnvironments + summary: Suspends the hostingEnvironment. + operationId: HostingEnvironments_SuspendHostingEnvironment + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/hostingEnvironments/{name}/resume': + post: + tags: + - HostingEnvironments + summary: Resumes the hostingEnvironment. + operationId: HostingEnvironments_ResumeHostingEnvironment + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of hostingEnvironment (App Service Environment) + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments/{name}': + get: + tags: + - ManagedHostingEnvironments + summary: Get properties of a managed hosting environment. + operationId: ManagedHostingEnvironments_GetManagedHostingEnvironment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ManagedHostingEnvironment' + deprecated: false + put: + tags: + - ManagedHostingEnvironments + summary: Create or update a managed hosting environment. + operationId: ManagedHostingEnvironments_CreateOrUpdateManagedHostingEnvironment + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - name: ManagedHostingEnvironmentEnvelope + in: body + description: Properties of managed hosting environment + required: true + schema: + $ref: '#/definitions/HostingEnvironment' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/HostingEnvironment' + '400': + description: Bad request + '404': + description: Not found + '409': + description: Conflict + deprecated: false + x-ms-long-running-operation: true + delete: + tags: + - ManagedHostingEnvironments + summary: Delete a managed hosting environment. + operationId: ManagedHostingEnvironments_DeleteManagedHostingEnvironment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - name: forceDelete + in: query + description: Delete even if the managed hosting environment contains resources + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Object' + '400': + description: Bad request + '404': + description: Not found + '409': + description: Conflict + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments': + get: + tags: + - ManagedHostingEnvironments + summary: Get all managed hosting environments in a resource group. + operationId: ManagedHostingEnvironments_GetManagedHostingEnvironments + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostingEnvironmentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments/{name}/capacities/virtualip': + get: + tags: + - ManagedHostingEnvironments + summary: Get list of ip addresses assigned to a managed hosting environment + operationId: ManagedHostingEnvironments_GetManagedHostingEnvironmentVips + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/AddressResponse' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments/{name}/operations/{operationId}': + get: + tags: + - ManagedHostingEnvironments + summary: Get status of an operation on a managed hosting environment. + operationId: ManagedHostingEnvironments_GetManagedHostingEnvironmentOperation + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - name: operationId + in: path + description: operation identifier GUID + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: Operation completed successfully + schema: + $ref: '#/definitions/Object' + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Object' + '404': + description: Not found + '500': + description: Operation failed + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments/{name}/sites': + get: + tags: + - ManagedHostingEnvironments + summary: Get all sites on the managed hosting environment. + operationId: ManagedHostingEnvironments_GetManagedHostingEnvironmentSites + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - name: propertiesToInclude + in: query + description: Comma separated list of site properties to include + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments/{name}/webhostingplans': + get: + tags: + - ManagedHostingEnvironments + summary: >- + Get all serverfarms (App Service Plans) on the managed hosting + environment. + operationId: ManagedHostingEnvironments_GetManagedHostingEnvironmentWebHostingPlans + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments/{name}/serverfarms': + get: + tags: + - ManagedHostingEnvironments + summary: >- + Get all serverfarms (App Service Plans) on the managed hosting + environment. + operationId: ManagedHostingEnvironments_GetManagedHostingEnvironmentServerFarms + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of managed hosting environment + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmCollection' + deprecated: false + /providers/Microsoft.Web/sourcecontrols: + get: + tags: + - Provider + summary: Gets the source controls available for Azure websites + operationId: Provider_GetSourceControls + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SourceControlCollection' + deprecated: false + '/providers/Microsoft.Web/sourcecontrols/{sourceControlType}': + get: + tags: + - Provider + summary: Gets source control token + operationId: Provider_GetSourceControl + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: sourceControlType + in: path + description: Type of source control + required: true + type: string + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SourceControl' + deprecated: false + put: + tags: + - Provider + summary: Updates source control token + operationId: Provider_UpdateSourceControl + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: sourceControlType + in: path + description: Type of source control + required: true + type: string + - name: requestMessage + in: body + description: Source control token information + required: true + schema: + $ref: '#/definitions/SourceControl' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SourceControl' + deprecated: false + /providers/Microsoft.Web/publishingUsers/web: + get: + tags: + - Provider + summary: Gets publishing user + operationId: Provider_GetPublishingUser + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/User' + deprecated: false + put: + tags: + - Provider + summary: Updates publishing user + operationId: Provider_UpdatePublishingUser + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: requestMessage + in: body + description: Details of publishing user + required: true + schema: + $ref: '#/definitions/User' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/User' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations': + get: + tags: + - Recommendations + summary: >- + Gets a list of recommendations associated with the specified + subscription. + operationId: Recommendations_GetRecommendationBySubscription + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: featured + in: query + description: >- + If set, this API returns only the most critical recommendation among + the others. Otherwise this API returns all recommendations available + type: boolean + - name: $filter + in: query + description: >- + Return only channels specified in the filter. Filter is specified by + using OData syntax. Example: $filter=channels eq 'Api' or channel eq + 'Notification' + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/Recommendation' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/{name}': + get: + tags: + - Recommendations + summary: >- + Gets the detailed properties of the recommendation object for the + specified web site. + operationId: Recommendations_GetRuleDetailsBySiteName + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Resource group name + required: true + type: string + - name: siteName + in: path + description: Site name + required: true + type: string + - name: name + in: path + description: Recommendation rule name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RecommendationRule' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations': + get: + tags: + - Recommendations + summary: Gets a list of recommendations associated with the specified web site. + operationId: Recommendations_GetRecommendedRulesForSite + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Resource group name + required: true + type: string + - name: siteName + in: path + description: Site name + required: true + type: string + - name: featured + in: query + description: >- + If set, this API returns only the most critical recommendation among + the others. Otherwise this API returns all recommendations available + type: boolean + - name: siteSku + in: query + description: The name of site SKU. + type: string + - name: numSlots + in: query + description: The number of site slots associated to the site + type: integer + format: int32 + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/Recommendation' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendationHistory': + get: + tags: + - Recommendations + summary: >- + Gets the list of past recommendations optionally specified by the time + range. + operationId: Recommendations_GetRecommendationHistoryForSite + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Resource group name + required: true + type: string + - name: siteName + in: path + description: Site name + required: true + type: string + - name: startTime + in: query + description: >- + The start time of a time range to query, e.g. $filter=startTime eq + '2015-01-01T00:00:00Z' and endTime eq '2015-01-02T00:00:00Z' + type: string + - name: endTime + in: query + description: >- + The end time of a time range to query, e.g. $filter=startTime eq + '2015-01-01T00:00:00Z' and endTime eq '2015-01-02T00:00:00Z' + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/Recommendation' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms': + get: + tags: + - ServerFarms + summary: >- + Gets collection of App Service Plans in a resource group for a given + subscription. + operationId: ServerFarms_GetServerFarms + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}': + get: + tags: + - ServerFarms + summary: Gets specified App Service Plan in a resource group + operationId: ServerFarms_GetServerFarm + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmWithRichSku' + deprecated: false + put: + tags: + - ServerFarms + summary: Creates or updates an App Service Plan + operationId: ServerFarms_CreateOrUpdateServerFarm + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: serverFarmEnvelope + in: body + description: Details of App Service Plan + required: true + schema: + $ref: '#/definitions/ServerFarmWithRichSku' + - name: allowPendingState + in: query + description: 'OBSOLETE: If true, allow pending state for App Service Plan' + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmWithRichSku' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/ServerFarmWithRichSku' + deprecated: false + x-ms-long-running-operation: true + delete: + tags: + - ServerFarms + summary: Deletes a App Service Plan + operationId: ServerFarms_DeleteServerFarm + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/metrics': + get: + tags: + - ServerFarms + summary: Queries for App Serice Plan metrics + operationId: ServerFarms_GetServerFarmMetrics + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: details + in: query + description: 'If true, metrics are broken down per App Service Plan instance' + type: boolean + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ResourceMetricCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/metricdefinitions': + get: + tags: + - ServerFarms + summary: List of metrics that can be queried for an App Service Plan + operationId: ServerFarms_GetServerFarmMetricDefintions + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/MetricDefinitionCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections': + get: + tags: + - ServerFarms + summary: Gets list of vnets associated with App Service Plan + operationId: ServerFarms_GetVnetsForServerFarm + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/VnetInfo' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}': + get: + tags: + - ServerFarms + summary: Gets a vnet associated with an App Service Plan + operationId: ServerFarms_GetVnetFromServerFarm + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: vnetName + in: path + description: Name of virtual network + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetInfo' + '404': + description: Virtual network could not be found + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes': + get: + tags: + - ServerFarms + summary: 'Gets a list of all routes associated with a vnet, in an app service plan' + operationId: ServerFarms_GetRoutesForVnet + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: vnetName + in: path + description: Name of virtual network + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/VnetRoute' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}': + get: + tags: + - ServerFarms + summary: 'Gets a specific route associated with a vnet, in an app service plan' + operationId: ServerFarms_GetRouteForVnet + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: vnetName + in: path + description: Name of virtual network + required: true + type: string + - name: routeName + in: path + description: Name of the virtual network route + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/VnetRoute' + '404': + description: Specified route does not exist + deprecated: false + put: + tags: + - ServerFarms + summary: >- + Creates a new route or updates an existing route for a vnet in an app + service plan. + operationId: ServerFarms_CreateOrUpdateVnetRoute + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: vnetName + in: path + description: Name of virtual network + required: true + type: string + - name: routeName + in: path + description: Name of the virtual network route + required: true + type: string + - name: route + in: body + description: The route object + required: true + schema: + $ref: '#/definitions/VnetRoute' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetRoute' + '400': + description: >- + Invalid request. Ensure that required parameters are given, and that + addresses and address spaces are valid + '404': + description: Route not found. This will only occur when using the PATCH verb. + deprecated: false + delete: + tags: + - ServerFarms + summary: Deletes an existing route for a vnet in an app service plan. + operationId: ServerFarms_DeleteVnetRoute + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: vnetName + in: path + description: Name of virtual network + required: true + type: string + - name: routeName + in: path + description: Name of the virtual network route + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + '404': + description: Specified route does not exist. + deprecated: false + patch: + tags: + - ServerFarms + summary: >- + Creates a new route or updates an existing route for a vnet in an app + service plan. + operationId: ServerFarms_UpdateVnetRoute + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: vnetName + in: path + description: Name of virtual network + required: true + type: string + - name: routeName + in: path + description: Name of the virtual network route + required: true + type: string + - name: route + in: body + description: The route object + required: true + schema: + $ref: '#/definitions/VnetRoute' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetRoute' + '400': + description: >- + Invalid request. Ensure that required parameters are given, and that + addresses and address spaces are valid + '404': + description: Route not found. This will only occur when using the PATCH verb. + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/gateways/{gatewayName}': + get: + tags: + - ServerFarms + summary: Gets the vnet gateway. + operationId: ServerFarms_GetServerFarmVnetGateway + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of the App Service Plan + required: true + type: string + - name: vnetName + in: path + description: Name of the virtual network + required: true + type: string + - name: gatewayName + in: path + description: Name of the gateway. Only the 'primary' gateway is supported. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetGateway' + deprecated: false + put: + tags: + - ServerFarms + summary: Updates the vnet gateway + operationId: ServerFarms_UpdateServerFarmVnetGateway + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group + required: true + type: string + - name: name + in: path + description: The name of the App Service Plan + required: true + type: string + - name: vnetName + in: path + description: The name of the virtual network + required: true + type: string + - name: gatewayName + in: path + description: The name of the gateway. Only 'primary' is supported. + required: true + type: string + - name: connectionEnvelope + in: body + description: The gateway entity. + required: true + schema: + $ref: '#/definitions/VnetGateway' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetGateway' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/sites': + get: + tags: + - ServerFarms + summary: Gets list of Apps associated with an App Service Plan + operationId: ServerFarms_GetServerFarmSites + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: $skipToken + in: query + description: >- + Skip to of web apps in a list. If specified, the resulting list will + contain web apps starting from (including) the skipToken. Else, the + resulting list contains web apps from the start of the list + type: string + - name: $filter + in: query + description: >- + Supported filter: $filter=state eq running. Returns only web apps + that are currently running + type: string + - name: $top + in: query + description: 'List page size. If specified, results are paged.' + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + x-ms-pageable: + nextLinkName: nextLink + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/workers/{workerName}/reboot': + post: + tags: + - ServerFarms + summary: >- + Submit a reboot request for a worker machine in the specified server + farm + operationId: ServerFarms_RebootWorkerForServerFarm + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of server farm + required: true + type: string + - name: workerName + in: path + description: 'Name of worker machine, typically starts with RD' + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/restartSites': + post: + tags: + - ServerFarms + summary: Restarts web apps in a specified App Service Plan + operationId: ServerFarms_RestartSitesForServerFarm + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of App Service Plan + required: true + type: string + - name: softRestart + in: query + description: >- + Soft restart applies the configuration settings and restarts the + apps if necessary. Hard restart always restarts and reprovisions the + apps + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/operationresults/{operationId}': + get: + tags: + - ServerFarms + summary: Gets a server farm operation + operationId: ServerFarms_GetServerFarmOperation + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of server farm + required: true + type: string + - name: operationId + in: path + description: Id of Server farm operation"> + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ServerFarmWithRichSku' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/virtualNetworkConnections/{vnetName}': + get: + tags: + - Sites + summary: >- + Retrieves a specific Virtual Network Connection associated with this web + app. + operationId: Sites_GetSiteVNETConnectionSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetInfo' + deprecated: false + put: + tags: + - Sites + summary: Adds a Virtual Network Connection or updates it's properties. + operationId: Sites_CreateOrUpdateSiteVNETConnectionSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties of this Virtual Network Connection + required: true + schema: + $ref: '#/definitions/VnetInfo' + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetInfo' + deprecated: false + delete: + tags: + - Sites + summary: >- + Removes the specified Virtual Network Connection association from this + web app. + operationId: Sites_DeleteSiteVNETConnectionSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Sites + summary: Adds a Virtual Network Connection or updates it's properties. + operationId: Sites_UpdateSiteVNETConnectionSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties of this Virtual Network Connection + required: true + schema: + $ref: '#/definitions/VnetInfo' + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetInfo' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/virtualNetworkConnections/{vnetName}': + get: + tags: + - Sites + summary: >- + Retrieves a specific Virtual Network Connection associated with this web + app. + operationId: Sites_GetSiteVNETConnection + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetInfo' + deprecated: false + put: + tags: + - Sites + summary: Adds a Virtual Network Connection or updates it's properties. + operationId: Sites_CreateOrUpdateSiteVNETConnection + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties of this Virtual Network Connection + required: true + schema: + $ref: '#/definitions/VnetInfo' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetInfo' + deprecated: false + delete: + tags: + - Sites + summary: >- + Removes the specified Virtual Network Connection association from this + web app. + operationId: Sites_DeleteSiteVNETConnection + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Sites + summary: Adds a Virtual Network Connection or updates it's properties. + operationId: Sites_UpdateSiteVNETConnection + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties of this Virtual Network Connection + required: true + schema: + $ref: '#/definitions/VnetInfo' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetInfo' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/networkFeatures/{view}': + get: + tags: + - Sites + summary: Retrieves a view of all network features in use on this web app. + operationId: Sites_GetSiteNetworkFeaturesSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: view + in: path + description: The type of view. This can either be "summary" or "detailed". + required: true + type: string + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/NetworkFeatures' + '404': + description: The requested view does not exist. + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/networkFeatures/{view}': + get: + tags: + - Sites + summary: Retrieves a view of all network features in use on this web app. + operationId: Sites_GetSiteNetworkFeatures + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: view + in: path + description: The type of view. This can either be "summary" or "detailed". + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/NetworkFeatures' + '404': + description: The requested view does not exist. + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/operationresults/{operationId}': + get: + tags: + - Sites + summary: Gets the operation for a web app + operationId: Sites_GetSiteOperationSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: operationId + in: path + description: Id of an operation + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/operationresults/{operationId}': + get: + tags: + - Sites + summary: Gets the operation for a web app + operationId: Sites_GetSiteOperation + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: operationId + in: path + description: Id of an operation + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slotsswap': + post: + tags: + - Sites + summary: Swaps web app slots + operationId: Sites_SwapSlotWithProduction + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slotSwapEntity + in: body + description: Request body that contains the target slot name + required: true + schema: + $ref: '#/definitions/CsmSlotEntity' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/Object' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/slotsswap': + post: + tags: + - Sites + summary: Swaps web app slots + operationId: Sites_SwapSlotsSlot + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slotSwapEntity + in: body + description: Request body that contains the target slot name + required: true + schema: + $ref: '#/definitions/CsmSlotEntity' + - name: slot + in: path + description: Name of source slot for the swap + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + '202': + description: Operation is in progress + schema: + $ref: '#/definitions/Object' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slotsdiffs': + post: + tags: + - Sites + summary: Get the difference in configuration settings between two web app slots + operationId: Sites_GetSlotsDifferencesFromProduction + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slotSwapEntity + in: body + description: Request body that contains the target slot name + required: true + schema: + $ref: '#/definitions/CsmSlotEntity' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SlotDifferenceCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/slotsdiffs': + post: + tags: + - Sites + summary: Get the difference in configuration settings between two web app slots + operationId: Sites_GetSlotsDifferencesSlot + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slotSwapEntity + in: body + description: Request body that contains the target slot name + required: true + schema: + $ref: '#/definitions/CsmSlotEntity' + - name: slot + in: path + description: Name of the source slot + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SlotDifferenceCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/applySlotConfig': + post: + tags: + - Sites + summary: >- + Applies the configuration settings from the target slot onto the current + slot + operationId: Sites_ApplySlotConfigToProduction + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slotSwapEntity + in: body + description: >- + Request body that contains the target slot name. Settings from that + slot will be applied on the source slot + required: true + schema: + $ref: '#/definitions/CsmSlotEntity' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/applySlotConfig': + post: + tags: + - Sites + summary: >- + Applies the configuration settings from the target slot onto the current + slot + operationId: Sites_ApplySlotConfigSlot + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slotSwapEntity + in: body + description: >- + Request body that contains the target slot name. Settings from that + slot will be applied on the source slot + required: true + schema: + $ref: '#/definitions/CsmSlotEntity' + - name: slot + in: path + description: >- + Name of the source slot. Settings from the target slot will be + applied onto this slot + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/resetSlotConfig': + post: + tags: + - Sites + summary: >- + Resets the configuration settings of the current slot if they were + previously modified by calling ApplySlotConfig API + operationId: Sites_ResetProductionSlotConfig + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/resetSlotConfig': + post: + tags: + - Sites + summary: >- + Resets the configuration settings of the current slot if they were + previously modified by calling ApplySlotConfig API + operationId: Sites_ResetSlotConfigSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/slotConfigNames': + get: + tags: + - Sites + summary: >- + Gets the names of application settings and connection string that remain + with the slot during swap operation + operationId: Sites_GetSlotConfigNames + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SlotConfigNamesResource' + deprecated: false + put: + tags: + - Sites + summary: >- + Updates the names of application settings and connection string that + remain with the slot during swap operation + operationId: Sites_UpdateSlotConfigNames + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slotConfigNames + in: body + description: >- + Request body containing the names of application settings and + connection strings + required: true + schema: + $ref: '#/definitions/SlotConfigNamesResource' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SlotConfigNamesResource' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots': + get: + tags: + - Sites + summary: Gets all the slots for a web apps + operationId: Sites_GetSiteSlots + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: propertiesToInclude + in: query + description: List of app properties to include in the response + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites': + get: + tags: + - Sites + summary: Gets the web apps for a subscription in the specified resource group + operationId: Sites_GetSites + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: propertiesToInclude + in: query + description: Additional web app properties included in the response + type: string + - name: includeSiteTypes + in: query + description: Types of apps included in the response + type: string + - name: includeSlots + in: query + description: Whether or not to include deployments slots in results + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}': + get: + tags: + - Sites + summary: Get details of a web app + operationId: Sites_GetSite + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: propertiesToInclude + in: query + description: Additional web app properties included in the response + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Site' + deprecated: false + put: + tags: + - Sites + summary: Creates a new web app or modifies an existing web app. + operationId: Sites_CreateOrUpdateSite + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the web app + required: true + type: string + - name: siteEnvelope + in: body + description: Details of web app if it exists already + required: true + schema: + $ref: '#/definitions/Site' + - name: skipDnsRegistration + in: query + description: "If true web app hostname is not registered with DNS on creation. This parameter is\r\n only used for app creation" + type: string + - name: skipCustomDomainVerification + in: query + description: >- + If true, custom (non *.azurewebsites.net) domains associated with + web app are not verified. + type: string + - name: forceDnsRegistration + in: query + description: 'If true, web app hostname is force registered with DNS' + type: string + - name: ttlInSeconds + in: query + description: Time to live in seconds for web app's default domain name + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Site' + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Site' + deprecated: false + x-ms-long-running-operation: true + delete: + tags: + - Sites + summary: Deletes a web app + operationId: Sites_DeleteSite + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: deleteMetrics + in: query + description: 'If true, web app metrics are also deleted' + type: string + - name: deleteEmptyServerFarm + in: query + description: >- + If true and App Service Plan is empty after web app deletion, App + Service Plan is also deleted + type: string + - name: skipDnsRegistration + in: query + description: 'If true, DNS registration is skipped' + type: string + - name: deleteAllSlots + in: query + description: 'If true, all slots associated with web app are also deleted' + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}': + get: + tags: + - Sites + summary: Get details of a web app + operationId: Sites_GetSiteSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: propertiesToInclude + in: query + description: Additional web app properties included in the response + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Site' + deprecated: false + put: + tags: + - Sites + summary: Creates a new web app or modifies an existing web app. + operationId: Sites_CreateOrUpdateSiteSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the web app + required: true + type: string + - name: siteEnvelope + in: body + description: Details of web app if it exists already + required: true + schema: + $ref: '#/definitions/Site' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: skipDnsRegistration + in: query + description: "If true web app hostname is not registered with DNS on creation. This parameter is\r\n only used for app creation" + type: string + - name: skipCustomDomainVerification + in: query + description: >- + If true, custom (non *.azurewebsites.net) domains associated with + web app are not verified. + type: string + - name: forceDnsRegistration + in: query + description: 'If true, web app hostname is force registered with DNS' + type: string + - name: ttlInSeconds + in: query + description: Time to live in seconds for web app's default domain name + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Site' + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Site' + deprecated: false + x-ms-long-running-operation: true + delete: + tags: + - Sites + summary: Deletes a web app + operationId: Sites_DeleteSiteSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: deleteMetrics + in: query + description: 'If true, web app metrics are also deleted' + type: string + - name: deleteEmptyServerFarm + in: query + description: >- + If true and App Service Plan is empty after web app deletion, App + Service Plan is also deleted + type: string + - name: skipDnsRegistration + in: query + description: 'If true, DNS registration is skipped' + type: string + - name: deleteAllSlots + in: query + description: 'If true, all slots associated with web app are also deleted' + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/iscloneable': + post: + tags: + - Sites + summary: Creates a new web app or modifies an existing web app. + operationId: Sites_IsSiteCloneable + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCloneability' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/iscloneable': + post: + tags: + - Sites + summary: Creates a new web app or modifies an existing web app. + operationId: Sites_IsSiteCloneableSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of the resource group + required: true + type: string + - name: name + in: path + description: Name of the web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteCloneability' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/recover': + post: + tags: + - Sites + summary: Recovers a deleted web app + operationId: Sites_RecoverSite + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: recoveryEntity + in: body + description: >- + Snapshot data used for web app recovery. Snapshot information can be + obtained by calling GetDeletedSites or GetSiteSnapshots API. + required: true + schema: + $ref: '#/definitions/CsmSiteRecoveryEntity' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Site' + '404': + description: Web app not found + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/recover': + post: + tags: + - Sites + summary: Recovers a deleted web app + operationId: Sites_RecoverSiteSlot + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: recoveryEntity + in: body + description: >- + Snapshot data used for web app recovery. Snapshot information can be + obtained by calling GetDeletedSites or GetSiteSnapshots API. + required: true + schema: + $ref: '#/definitions/CsmSiteRecoveryEntity' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '202': + description: Asynchronous operation in progress + schema: + $ref: '#/definitions/Site' + '404': + description: Web app not found + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/snapshots': + put: + tags: + - Sites + summary: Returns all Snapshots to the user. + operationId: Sites_GetSiteSnapshots + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Webspace + required: true + type: string + - name: name + in: path + description: Website Name + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/snapshots': + put: + tags: + - Sites + summary: Returns all Snapshots to the user. + operationId: Sites_GetSiteSnapshotsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Webspace + required: true + type: string + - name: name + in: path + description: Website Name + required: true + type: string + - name: slot + in: path + description: Website Slot + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/deletedSites': + get: + tags: + - Sites + summary: Gets deleted web apps in subscription + operationId: Sites_GetDeletedSites + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: propertiesToInclude + in: query + description: Additional web app properties included in the response + type: string + - name: includeSiteTypes + in: query + description: Types of apps included in the response + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DeletedSiteCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/deployments': + get: + tags: + - Sites + summary: List deployments + operationId: Sites_GetDeployments + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DeploymentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/deployments': + get: + tags: + - Sites + summary: List deployments + operationId: Sites_GetDeploymentsSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DeploymentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances/{instanceId}/deployments': + get: + tags: + - Sites + summary: List deployments + operationId: Sites_GetInstanceDeployments + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DeploymentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/instances/{instanceId}/deployments': + get: + tags: + - Sites + summary: List deployments + operationId: Sites_GetInstanceDeploymentsSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/DeploymentCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances/{instanceId}/deployments/{id}': + get: + tags: + - Sites + summary: Get the deployment + operationId: Sites_GetInstanceDeployment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + put: + tags: + - Sites + summary: Create a deployment + operationId: Sites_CreateInstanceDeployment + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - name: deployment + in: body + description: Details of deployment + required: true + schema: + $ref: '#/definitions/Deployment' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + delete: + tags: + - Sites + summary: Delete the deployment + operationId: Sites_DeleteInstanceDeployment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/deployments/{id}': + get: + tags: + - Sites + summary: Get the deployment + operationId: Sites_GetDeployment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + put: + tags: + - Sites + summary: Create a deployment + operationId: Sites_CreateDeployment + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: deployment + in: body + description: Details of deployment + required: true + schema: + $ref: '#/definitions/Deployment' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + delete: + tags: + - Sites + summary: Delete the deployment + operationId: Sites_DeleteDeployment + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/deployments/{id}': + get: + tags: + - Sites + summary: Get the deployment + operationId: Sites_GetDeploymentSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + put: + tags: + - Sites + summary: Create a deployment + operationId: Sites_CreateDeploymentSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: deployment + in: body + description: Details of deployment + required: true + schema: + $ref: '#/definitions/Deployment' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + delete: + tags: + - Sites + summary: Delete the deployment + operationId: Sites_DeleteDeploymentSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/instances/{instanceId}/deployments/{id}': + get: + tags: + - Sites + summary: Get the deployment + operationId: Sites_GetInstanceDeploymentSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + put: + tags: + - Sites + summary: Create a deployment + operationId: Sites_CreateInstanceDeploymentSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - name: deployment + in: body + description: Details of deployment + required: true + schema: + $ref: '#/definitions/Deployment' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Deployment' + deprecated: false + delete: + tags: + - Sites + summary: Delete the deployment + operationId: Sites_DeleteInstanceDeploymentSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: id + in: path + description: Id of the deployment + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: instanceId + in: path + description: Id of web app instance + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances': + get: + tags: + - Sites + summary: Gets all instance of a web app + operationId: Sites_GetSiteInstanceIdentifiers + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteInstanceCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/instances': + get: + tags: + - Sites + summary: Gets all instance of a web app + operationId: Sites_GetSiteInstanceIdentifiersSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteInstanceCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/hostNameBindings': + get: + tags: + - Sites + summary: Get web app hostname bindings + operationId: Sites_GetSiteHostNameBindings + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostNameBindingCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/hostNameBindings': + get: + tags: + - Sites + summary: Get web app hostname bindings + operationId: Sites_GetSiteHostNameBindingsSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostNameBindingCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/hostNameBindings/{hostName}': + get: + tags: + - Sites + summary: Get web app binding for a hostname + operationId: Sites_GetSiteHostNameBinding + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: hostName + in: path + description: Name of host + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostNameBinding' + deprecated: false + put: + tags: + - Sites + summary: Creates a web app hostname binding + operationId: Sites_CreateOrUpdateSiteHostNameBinding + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: hostName + in: path + description: Name of host + required: true + type: string + - name: hostNameBinding + in: body + description: Host name binding information + required: true + schema: + $ref: '#/definitions/HostNameBinding' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostNameBinding' + deprecated: false + delete: + tags: + - Sites + summary: Deletes a host name binding + operationId: Sites_DeleteSiteHostNameBinding + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: hostName + in: path + description: Name of host + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/hostNameBindings/{hostName}': + get: + tags: + - Sites + summary: Get web app binding for a hostname + operationId: Sites_GetSiteHostNameBindingSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: hostName + in: path + description: Name of host + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostNameBinding' + deprecated: false + put: + tags: + - Sites + summary: Creates a web app hostname binding + operationId: Sites_CreateOrUpdateSiteHostNameBindingSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: hostName + in: path + description: Name of host + required: true + type: string + - name: hostNameBinding + in: body + description: Host name binding information + required: true + schema: + $ref: '#/definitions/HostNameBinding' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/HostNameBinding' + deprecated: false + delete: + tags: + - Sites + summary: Deletes a host name binding + operationId: Sites_DeleteSiteHostNameBindingSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: hostName + in: path + description: Name of host + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/web': + get: + tags: + - Sites + summary: Gets the configuration of the web app + operationId: Sites_GetSiteConfig + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteConfig' + deprecated: false + put: + tags: + - Sites + summary: Update the configuration of web app + operationId: Sites_CreateOrUpdateSiteConfig + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteConfig + in: body + description: Request body that contains the configuraiton setting for the web app + required: true + schema: + $ref: '#/definitions/SiteConfig' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteConfig' + deprecated: false + patch: + tags: + - Sites + summary: Update the configuration of web app + operationId: Sites_UpdateSiteConfig + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteConfig + in: body + description: Request body that contains the configuraiton setting for the web app + required: true + schema: + $ref: '#/definitions/SiteConfig' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteConfig' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/web': + get: + tags: + - Sites + summary: Gets the configuration of the web app + operationId: Sites_GetSiteConfigSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteConfig' + deprecated: false + put: + tags: + - Sites + summary: Update the configuration of web app + operationId: Sites_CreateOrUpdateSiteConfigSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteConfig + in: body + description: Request body that contains the configuraiton setting for the web app + required: true + schema: + $ref: '#/definitions/SiteConfig' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteConfig' + deprecated: false + patch: + tags: + - Sites + summary: Update the configuration of web app + operationId: Sites_UpdateSiteConfigSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteConfig + in: body + description: Request body that contains the configuraiton setting for the web app + required: true + schema: + $ref: '#/definitions/SiteConfig' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteConfig' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/sourcecontrols/web': + get: + tags: + - Sites + summary: Get the source control configuration of web app + operationId: Sites_GetSiteSourceControl + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteSourceControl' + deprecated: false + put: + tags: + - Sites + summary: Update the source control configuration of web app + operationId: Sites_CreateOrUpdateSiteSourceControl + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteSourceControl + in: body + description: Request body that contains the source control parameters + required: true + schema: + $ref: '#/definitions/SiteSourceControl' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteSourceControl' + deprecated: false + delete: + tags: + - Sites + summary: Delete source control configuration of web app + operationId: Sites_DeleteSiteSourceControl + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Sites + summary: Update the source control configuration of web app + operationId: Sites_UpdateSiteSourceControl + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteSourceControl + in: body + description: Request body that contains the source control parameters + required: true + schema: + $ref: '#/definitions/SiteSourceControl' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteSourceControl' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/sourcecontrols/web': + get: + tags: + - Sites + summary: Get the source control configuration of web app + operationId: Sites_GetSiteSourceControlSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteSourceControl' + deprecated: false + put: + tags: + - Sites + summary: Update the source control configuration of web app + operationId: Sites_CreateOrUpdateSiteSourceControlSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteSourceControl + in: body + description: Request body that contains the source control parameters + required: true + schema: + $ref: '#/definitions/SiteSourceControl' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteSourceControl' + deprecated: false + delete: + tags: + - Sites + summary: Delete source control configuration of web app + operationId: Sites_DeleteSiteSourceControlSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Sites + summary: Update the source control configuration of web app + operationId: Sites_UpdateSiteSourceControlSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteSourceControl + in: body + description: Request body that contains the source control parameters + required: true + schema: + $ref: '#/definitions/SiteSourceControl' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteSourceControl' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/appsettings/list': + post: + tags: + - Sites + summary: Gets the application settings of web app + operationId: Sites_ListSiteAppSettingsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/appsettings/list': + post: + tags: + - Sites + summary: Gets the application settings of web app + operationId: Sites_ListSiteAppSettings + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/appsettings': + put: + tags: + - Sites + summary: Updates the application settings of web app + operationId: Sites_UpdateSiteAppSettings + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: appSettings + in: body + description: Application settings of web app + required: true + schema: + $ref: '#/definitions/StringDictionary' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/appsettings': + put: + tags: + - Sites + summary: Updates the application settings of web app + operationId: Sites_UpdateSiteAppSettingsSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: appSettings + in: body + description: Application settings of web app + required: true + schema: + $ref: '#/definitions/StringDictionary' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/connectionstrings/list': + post: + tags: + - Sites + summary: Gets the connection strings associated with web app + operationId: Sites_ListSiteConnectionStrings + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ConnectionStringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/connectionstrings/list': + post: + tags: + - Sites + summary: Gets the connection strings associated with web app + operationId: Sites_ListSiteConnectionStringsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ConnectionStringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/connectionstrings': + put: + tags: + - Sites + summary: Updates the connection strings associated with web app + operationId: Sites_UpdateSiteConnectionStrings + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: connectionStrings + in: body + description: Connection strings associated with web app + required: true + schema: + $ref: '#/definitions/ConnectionStringDictionary' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ConnectionStringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/connectionstrings': + put: + tags: + - Sites + summary: Updates the connection strings associated with web app + operationId: Sites_UpdateSiteConnectionStringsSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: connectionStrings + in: body + description: Connection strings associated with web app + required: true + schema: + $ref: '#/definitions/ConnectionStringDictionary' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ConnectionStringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/authsettings/list': + post: + tags: + - Sites + summary: Gets the Authentication / Authorization settings associated with web app + operationId: Sites_ListSiteAuthSettings + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteAuthSettings' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/authsettings/list': + post: + tags: + - Sites + summary: Gets the Authentication / Authorization settings associated with web app + operationId: Sites_ListSiteAuthSettingsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteAuthSettings' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/authsettings': + put: + tags: + - Sites + summary: >- + Updates the Authentication / Authorization settings associated with web + app + operationId: Sites_UpdateSiteAuthSettings + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteAuthSettings + in: body + description: Auth settings associated with web app + required: true + schema: + $ref: '#/definitions/SiteAuthSettings' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteAuthSettings' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/authsettings': + put: + tags: + - Sites + summary: >- + Updates the Authentication / Authorization settings associated with web + app + operationId: Sites_UpdateSiteAuthSettingsSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteAuthSettings + in: body + description: Auth settings associated with web app + required: true + schema: + $ref: '#/definitions/SiteAuthSettings' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteAuthSettings' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/publishingcredentials/list': + post: + tags: + - Sites + summary: Gets the web app publishing credentials + operationId: Sites_ListSitePublishingCredentials + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/User' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/publishingcredentials/list': + post: + tags: + - Sites + summary: Gets the web app publishing credentials + operationId: Sites_ListSitePublishingCredentialsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/User' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/metadata/list': + post: + tags: + - Sites + summary: Gets the web app meta data. + operationId: Sites_ListSiteMetadata + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/metadata/list': + post: + tags: + - Sites + summary: Gets the web app meta data. + operationId: Sites_ListSiteMetadataSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/metadata': + put: + tags: + - Sites + summary: Updates the meta data for web app + operationId: Sites_UpdateSiteMetadata + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: metadata + in: body + description: Meta data of web app + required: true + schema: + $ref: '#/definitions/StringDictionary' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/metadata': + put: + tags: + - Sites + summary: Updates the meta data for web app + operationId: Sites_UpdateSiteMetadataSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: metadata + in: body + description: Meta data of web app + required: true + schema: + $ref: '#/definitions/StringDictionary' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/StringDictionary' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/logs': + get: + tags: + - Sites + summary: Gets the web app logs configuration + operationId: Sites_GetSiteLogsConfig + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteLogsConfig' + deprecated: false + put: + tags: + - Sites + summary: Updates the meta data for web app + operationId: Sites_UpdateSiteLogsConfig + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteLogsConfig + in: body + description: Site logs configuration + required: true + schema: + $ref: '#/definitions/SiteLogsConfig' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteLogsConfig' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/logs': + get: + tags: + - Sites + summary: Gets the web app logs configuration + operationId: Sites_GetSiteLogsConfigSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteLogsConfig' + deprecated: false + put: + tags: + - Sites + summary: Updates the meta data for web app + operationId: Sites_UpdateSiteLogsConfigSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: siteLogsConfig + in: body + description: Site logs configuration + required: true + schema: + $ref: '#/definitions/SiteLogsConfig' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/SiteLogsConfig' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/premieraddons': + get: + tags: + - Sites + operationId: Sites_ListSitePremierAddOns + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/premieraddons': + get: + tags: + - Sites + operationId: Sites_ListSitePremierAddOnsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: slot + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/premieraddons/{premierAddOnName}': + get: + tags: + - Sites + operationId: Sites_GetSitePremierAddOn + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: premierAddOnName + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + put: + tags: + - Sites + operationId: Sites_AddSitePremierAddOn + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: premierAddOnName + in: path + required: true + type: string + - name: premierAddOn + in: body + required: true + schema: + $ref: '#/definitions/PremierAddOnRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + delete: + tags: + - Sites + operationId: Sites_DeleteSitePremierAddOn + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: premierAddOnName + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/premieraddons/{premierAddOnName}': + get: + tags: + - Sites + operationId: Sites_GetSitePremierAddOnSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: premierAddOnName + in: path + required: true + type: string + - name: slot + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + put: + tags: + - Sites + operationId: Sites_AddSitePremierAddOnSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: premierAddOnName + in: path + required: true + type: string + - name: premierAddOn + in: body + required: true + schema: + $ref: '#/definitions/PremierAddOnRequest' + - name: slot + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + delete: + tags: + - Sites + operationId: Sites_DeleteSitePremierAddOnSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: premierAddOnName + in: path + required: true + type: string + - name: slot + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/backup/list': + post: + tags: + - Sites + summary: Gets the backup configuration for a web app + operationId: Sites_GetSiteBackupConfiguration + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupRequest' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/backup/list': + post: + tags: + - Sites + summary: Gets the backup configuration for a web app + operationId: Sites_GetSiteBackupConfigurationSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupRequest' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/backup': + put: + tags: + - Sites + summary: Updates backup configuration of web app + operationId: Sites_UpdateSiteBackupConfiguration + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: request + in: body + description: Information on backup request + required: true + schema: + $ref: '#/definitions/BackupRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupRequest' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/config/backup': + put: + tags: + - Sites + summary: Updates backup configuration of web app + operationId: Sites_UpdateSiteBackupConfigurationSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: request + in: body + description: Information on backup request + required: true + schema: + $ref: '#/definitions/BackupRequest' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupRequest' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/backup': + post: + tags: + - Sites + summary: Creates web app backup + operationId: Sites_BackupSite + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: request + in: body + description: Information on backup request + required: true + schema: + $ref: '#/definitions/BackupRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/backup': + post: + tags: + - Sites + summary: Creates web app backup + operationId: Sites_BackupSiteSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: request + in: body + description: Information on backup request + required: true + schema: + $ref: '#/definitions/BackupRequest' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/backups/discover': + put: + tags: + - Sites + summary: Discovers existing web app backups that can be restored + operationId: Sites_DiscoverSiteRestore + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: request + in: body + description: Information on restore request + required: true + schema: + $ref: '#/definitions/RestoreRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RestoreRequest' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/backups/discover': + put: + tags: + - Sites + summary: Discovers existing web app backups that can be restored + operationId: Sites_DiscoverSiteRestoreSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: request + in: body + description: Information on restore request + required: true + schema: + $ref: '#/definitions/RestoreRequest' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RestoreRequest' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/backups': + get: + tags: + - Sites + summary: Lists all available backups for web app + operationId: Sites_ListSiteBackups + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItemCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/backups': + get: + tags: + - Sites + summary: Lists all available backups for web app + operationId: Sites_ListSiteBackupsSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItemCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/backups/{backupId}': + get: + tags: + - Sites + summary: Gets status of a web app backup that may be in progress. + operationId: Sites_GetSiteBackupStatus + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + delete: + tags: + - Sites + summary: Deletes a backup from Azure Storage + operationId: Sites_DeleteBackup + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/backups/{backupId}': + get: + tags: + - Sites + summary: Gets status of a web app backup that may be in progress. + operationId: Sites_GetSiteBackupStatusSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + delete: + tags: + - Sites + summary: Deletes a backup from Azure Storage + operationId: Sites_DeleteBackupSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/backups/{backupId}/list': + post: + tags: + - Sites + summary: >- + Gets status of a web app backup that may be in progress, including + secrets associated with the backup, such as the Azure Storage SAS URL. + Also can be used to update the SAS URL for the backup if a new URL is + passed in the request body. + operationId: Sites_GetSiteBackupStatusSecretsSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup + required: true + type: string + - name: request + in: body + description: Information on backup request + required: true + schema: + $ref: '#/definitions/BackupRequest' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/backups/{backupId}/list': + post: + tags: + - Sites + summary: >- + Gets status of a web app backup that may be in progress, including + secrets associated with the backup, such as the Azure Storage SAS URL. + Also can be used to update the SAS URL for the backup if a new URL is + passed in the request body. + operationId: Sites_GetSiteBackupStatusSecrets + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup + required: true + type: string + - name: request + in: body + description: Information on backup request + required: true + schema: + $ref: '#/definitions/BackupRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/BackupItem' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/backups/{backupId}/restore': + post: + tags: + - Sites + summary: Restores a web app + operationId: Sites_RestoreSite + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup to restore + required: true + type: string + - name: request + in: body + description: Information on restore request + required: true + schema: + $ref: '#/definitions/RestoreRequest' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RestoreResponse' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/backups/{backupId}/restore': + post: + tags: + - Sites + summary: Restores a web app + operationId: Sites_RestoreSiteSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: backupId + in: path + description: Id of backup to restore + required: true + type: string + - name: request + in: body + description: Information on restore request + required: true + schema: + $ref: '#/definitions/RestoreRequest' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RestoreResponse' + deprecated: false + x-ms-long-running-operation: true + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/usages': + get: + tags: + - Sites + summary: Gets the quota usage numbers for web app + operationId: Sites_GetSiteUsages + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: $filter + in: query + description: >- + Return only usages specified in the filter. Filter is specified by + using OData syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CsmUsageQuotaCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/usages': + get: + tags: + - Sites + summary: Gets the quota usage numbers for web app + operationId: Sites_GetSiteUsagesSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: $filter + in: query + description: >- + Return only usages specified in the filter. Filter is specified by + using OData syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/CsmUsageQuotaCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/metrics': + get: + tags: + - Sites + summary: Gets metrics for web app + operationId: Sites_GetSiteMetrics + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: details + in: query + description: 'If true, metric details are included in response' + type: boolean + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ResourceMetricCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/metrics': + get: + tags: + - Sites + summary: Gets metrics for web app + operationId: Sites_GetSiteMetricsSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: details + in: query + description: 'If true, metric details are included in response' + type: boolean + - name: $filter + in: query + description: >- + Return only usages/metrics specified in the filter. Filter conforms + to odata syntax. Example: $filter=(name.value eq 'Metric1' or + name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and + endTime eq '2014-12-31T23:59:59Z' and timeGrain eq + duration'[Hour|Minute|Day]'. + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/ResourceMetricCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/metricdefinitions': + get: + tags: + - Sites + summary: Gets metric definitions for web app + operationId: Sites_GetSiteMetricDefinitionsSlot + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/MetricDefinitionCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/metricdefinitions': + get: + tags: + - Sites + summary: Gets metric definitions for web app + operationId: Sites_GetSiteMetricDefinitions + consumes: [] + produces: + - application/json + - text/json + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/MetricDefinitionCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/publishxml': + post: + tags: + - Sites + summary: Gets the publishing profile for web app + operationId: Sites_ListSitePublishingProfileXml + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: options + in: body + description: >- + Specifies options for publishing profile. Pass + CsmPublishingProfileOptions.Format=FileZilla3 for FileZilla FTP + format. + required: true + schema: + $ref: '#/definitions/CsmPublishingProfileOptions' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: file + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/publishxml': + post: + tags: + - Sites + summary: Gets the publishing profile for web app + operationId: Sites_ListSitePublishingProfileXmlSlot + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: options + in: body + description: >- + Specifies options for publishing profile. Pass + CsmPublishingProfileOptions.Format=FileZilla3 for FileZilla FTP + format. + required: true + schema: + $ref: '#/definitions/CsmPublishingProfileOptions' + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: file + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/restart': + post: + tags: + - Sites + summary: Restarts web app + operationId: Sites_RestartSiteSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - name: softRestart + in: query + description: >- + Soft restart applies the configuration settings and restarts the app + if necessary. Hard restart always restarts and reprovisions the app + type: boolean + - name: synchronous + in: query + description: If true then the API will block until the app has been restarted + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/restart': + post: + tags: + - Sites + summary: Restarts web app + operationId: Sites_RestartSite + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: softRestart + in: query + description: >- + Soft restart applies the configuration settings and restarts the app + if necessary. Hard restart always restarts and reprovisions the app + type: boolean + - name: synchronous + in: query + description: If true then the API will block until the app has been restarted + type: boolean + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/start': + post: + tags: + - Sites + summary: Starts web app + operationId: Sites_StartSite + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/start': + post: + tags: + - Sites + summary: Starts web app + operationId: Sites_StartSiteSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/stop': + post: + tags: + - Sites + summary: Stops web app + operationId: Sites_StopSite + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/stop': + post: + tags: + - Sites + summary: Stops web app + operationId: Sites_StopSiteSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/sync': + post: + tags: + - Sites + operationId: Sites_SyncSiteRepository + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/sync': + post: + tags: + - Sites + operationId: Sites_SyncSiteRepositorySlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + required: true + type: string + - name: name + in: path + required: true + type: string + - name: slot + in: path + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/newpassword': + post: + tags: + - Sites + summary: Generates new random app publishing password + operationId: Sites_GenerateNewSitePublishingPasswordSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - name: slot + in: path + description: >- + Name of web app slot. If not specified then will default to + production slot. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/newpassword': + post: + tags: + - Sites + summary: Generates new random app publishing password + operationId: Sites_GenerateNewSitePublishingPassword + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: name + in: path + description: Name of web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/hybridconnection/{entityName}': + get: + tags: + - Sites + summary: Retrieves a Biztalk Hybrid Connection identified by its entity name. + operationId: Sites_GetSiteRelayServiceConnection + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + put: + tags: + - Sites + summary: >- + Creates a new association to a Biztalk Hybrid Connection, or updates an + existing one. + operationId: Sites_CreateOrUpdateSiteRelayServiceConnection + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - name: connectionEnvelope + in: body + description: The details of the Hybrid Connection + required: true + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + delete: + tags: + - Sites + summary: >- + Removes the association to a Biztalk Hybrid Connection, identified by + its entity name. + operationId: Sites_DeleteSiteRelayServiceConnection + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Sites + summary: >- + Creates a new association to a Biztalk Hybrid Connection, or updates an + existing one. + operationId: Sites_UpdateSiteRelayServiceConnection + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - name: connectionEnvelope + in: body + description: The details of the Hybrid Connection + required: true + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/hybridconnection/{entityName}': + get: + tags: + - Sites + summary: Retrieves a Biztalk Hybrid Connection identified by its entity name. + operationId: Sites_GetSiteRelayServiceConnectionSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - name: slot + in: path + description: The name of the slot for the web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + put: + tags: + - Sites + summary: >- + Creates a new association to a Biztalk Hybrid Connection, or updates an + existing one. + operationId: Sites_CreateOrUpdateSiteRelayServiceConnectionSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - name: connectionEnvelope + in: body + description: The details of the Hybrid Connection + required: true + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + - name: slot + in: path + description: The name of the slot for the web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + delete: + tags: + - Sites + summary: >- + Removes the association to a Biztalk Hybrid Connection, identified by + its entity name. + operationId: Sites_DeleteSiteRelayServiceConnectionSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - name: slot + in: path + description: The name of the slot for the web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false + patch: + tags: + - Sites + summary: >- + Creates a new association to a Biztalk Hybrid Connection, or updates an + existing one. + operationId: Sites_UpdateSiteRelayServiceConnectionSlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: entityName + in: path + description: The name by which the Hybrid Connection is identified + required: true + type: string + - name: connectionEnvelope + in: body + description: The details of the Hybrid Connection + required: true + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + - name: slot + in: path + description: The name of the slot for the web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/hybridconnection': + get: + tags: + - Sites + summary: Retrieves all Biztalk Hybrid Connections associated with this web app. + operationId: Sites_ListSiteRelayServiceConnectionsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: slot + in: path + description: The name of the slot for the web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/hybridconnection': + get: + tags: + - Sites + summary: Retrieves all Biztalk Hybrid Connections associated with this web app. + operationId: Sites_ListSiteRelayServiceConnections + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/RelayServiceConnectionEntity' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/virtualNetworkConnections/{vnetName}/gateways/{gatewayName}': + get: + tags: + - Sites + summary: >- + Retrieves a Virtual Network connection gateway associated with this web + app and virtual network. + operationId: Sites_GetSiteVnetGatewaySlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: gatewayName + in: path + description: >- + The name of the gateway. The only gateway that exists presently is + "primary" + required: true + type: string + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + '404': + description: Gateway does not exist. Only the "primary" gateway exists presently. + deprecated: false + put: + tags: + - Sites + summary: Updates the Virtual Network Gateway. + operationId: Sites_CreateOrUpdateSiteVNETConnectionGatewaySlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: gatewayName + in: path + description: >- + The name of the gateway. The only gateway that exists presently is + "primary" + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties to update this gateway with. + required: true + schema: + $ref: '#/definitions/VnetGateway' + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetGateway' + deprecated: false + patch: + tags: + - Sites + summary: Updates the Virtual Network Gateway. + operationId: Sites_UpdateSiteVNETConnectionGatewaySlot + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: gatewayName + in: path + description: >- + The name of the gateway. The only gateway that exists presently is + "primary" + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties to update this gateway with. + required: true + schema: + $ref: '#/definitions/VnetGateway' + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetGateway' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/virtualNetworkConnections/{vnetName}/gateways/{gatewayName}': + get: + tags: + - Sites + summary: >- + Retrieves a Virtual Network connection gateway associated with this web + app and virtual network. + operationId: Sites_GetSiteVnetGateway + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: gatewayName + in: path + description: >- + The name of the gateway. The only gateway that exists presently is + "primary" + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + '404': + description: Gateway does not exist. Only the "primary" gateway exists presently. + deprecated: false + put: + tags: + - Sites + summary: Updates the Virtual Network Gateway. + operationId: Sites_CreateOrUpdateSiteVNETConnectionGateway + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: gatewayName + in: path + description: >- + The name of the gateway. The only gateway that exists presently is + "primary" + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties to update this gateway with. + required: true + schema: + $ref: '#/definitions/VnetGateway' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetGateway' + deprecated: false + patch: + tags: + - Sites + summary: Updates the Virtual Network Gateway. + operationId: Sites_UpdateSiteVNETConnectionGateway + consumes: + - application/json + - text/json + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: vnetName + in: path + description: The name of the Virtual Network + required: true + type: string + - name: gatewayName + in: path + description: >- + The name of the gateway. The only gateway that exists presently is + "primary" + required: true + type: string + - name: connectionEnvelope + in: body + description: The properties to update this gateway with. + required: true + schema: + $ref: '#/definitions/VnetGateway' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/VnetGateway' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/virtualNetworkConnections': + get: + tags: + - Sites + summary: >- + Retrieves a list of all Virtual Network Connections associated with this + web app. + operationId: Sites_GetSiteVNETConnections + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/VnetInfo' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/virtualNetworkConnections': + get: + tags: + - Sites + summary: >- + Retrieves a list of all Virtual Network Connections associated with this + web app. + operationId: Sites_GetSiteVNETConnectionsSlot + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: The resource group name + required: true + type: string + - name: name + in: path + description: The name of the web app + required: true + type: string + - name: slot + in: path + description: The name of the slot for this web app. + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + type: array + items: + $ref: '#/definitions/VnetInfo' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/topLevelDomains': + get: + tags: + - TopLevelDomains + summary: Lists all top level domains supported for registration + operationId: TopLevelDomains_GetGetTopLevelDomains + consumes: [] + produces: + - application/json + - text/json + parameters: + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/TopLevelDomainCollection' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/topLevelDomains/{name}': + get: + tags: + - TopLevelDomains + summary: Gets details of a top level domain + operationId: TopLevelDomains_GetTopLevelDomain + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: name + in: path + description: Name of the top level domain + required: true + type: string + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/TopLevelDomain' + deprecated: false + '/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/topLevelDomains/{name}/listAgreements': + post: + tags: + - TopLevelDomains + summary: >- + Lists legal agreements that user needs to accept before purchasing + domain + operationId: TopLevelDomains_ListTopLevelDomainAgreements + consumes: + - application/json + - text/json + - application/xml + - text/xml + - application/x-www-form-urlencoded + produces: + - application/json + - text/json + parameters: + - name: name + in: path + description: Name of the top level domain + required: true + type: string + - name: agreementOption + in: body + description: Domain agreement options + required: true + schema: + $ref: '#/definitions/TopLevelDomainAgreementOption' + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/TldLegalAgreementCollection' + deprecated: false + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web.Admin/environments/{environmentName}/usage': + get: + tags: + - Usage + summary: Returns usage records for specified subscription and resource groups + operationId: Usage_GetUsage + consumes: [] + produces: + - application/json + - text/json + - application/xml + - text/xml + parameters: + - name: resourceGroupName + in: path + description: Name of resource group + required: true + type: string + - name: environmentName + in: path + description: Environment name + required: true + type: string + - name: lastId + in: query + description: Last marker that was returned from the batch + required: true + type: string + - name: batchSize + in: query + description: size of the batch to be returned. + required: true + type: integer + format: int32 + - $ref: '#/parameters/subscriptionIdParameter' + - $ref: '#/parameters/apiVersionParameter' + responses: + '200': + description: OK + schema: + $ref: '#/definitions/Object' + deprecated: false +definitions: + ArmPlan: + description: 'The plan object in an ARM, represents a marketplace plan' + type: object + properties: + name: + description: The name + type: string + publisher: + description: The publisher + type: string + product: + description: The product + type: string + promotionCode: + description: The promotion code + type: string + version: + description: Version of product + type: string + CertificateOrderCertificate: + description: >- + Class representing the Key Vault container for certificate purchased + through Azure + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + keyVaultId: + description: Key Vault Csm resource Id + type: string + keyVaultSecretName: + description: Key Vault secret name + type: string + provisioningState: + description: Status of the Key Vault secret + enum: + - Initialized + - WaitingOnCertificateOrder + - Succeeded + - CertificateOrderFailed + - OperationNotPermittedOnKeyVault + - AzureServiceUnauthorizedToAccessKeyVault + - KeyVaultDoesNotExist + - KeyVaultSecretDoesNotExist + - UnknownError + - Unknown + type: string + x-ms-enum: + name: KeyVaultSecretStatus + modelAsString: false + x-ms-client-flatten: true + SkuDescription: + description: Describes a sku for a scalable resource + type: object + properties: + name: + description: Name of the resource sku + type: string + tier: + description: Service Tier of the resource sku + type: string + size: + description: Size specifier of the resource sku + type: string + family: + description: Family code of the resource sku + type: string + capacity: + format: int32 + description: Current number of instances assigned to the resource + type: integer + Object: + type: object + properties: {} + CertificateOrder: + description: Certificate purchase order + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + certificates: + description: State of the Key Vault secret + type: object + additionalProperties: + $ref: '#/definitions/CertificateOrderCertificate' + distinguishedName: + description: Certificate distinguished name + type: string + domainVerificationToken: + description: Domain Verification Token + type: string + validityInYears: + format: int32 + description: Duration in years (must be between 1 and 3) + type: integer + keySize: + format: int32 + description: Certificate Key Size + type: integer + productType: + description: Certificate product type + enum: + - StandardDomainValidatedSsl + - StandardDomainValidatedWildCardSsl + type: string + x-ms-enum: + name: CertificateProductType + modelAsString: false + autoRenew: + description: Auto renew + type: boolean + provisioningState: + description: Status of certificate order + enum: + - Succeeded + - Failed + - Canceled + - InProgress + - Deleting + type: string + x-ms-enum: + name: ProvisioningState + modelAsString: false + status: + description: Current order status + enum: + - Pendingissuance + - Issued + - Revoked + - Canceled + - Denied + - Pendingrevocation + - PendingRekey + - Unused + - Expired + - NotSubmitted + type: string + x-ms-enum: + name: CertificateOrderStatus + modelAsString: false + signedCertificate: + $ref: '#/definitions/CertificateDetails' + description: Signed certificate + csr: + description: Last CSR that was created for this order + type: string + intermediate: + $ref: '#/definitions/CertificateDetails' + description: Intermediate certificate + root: + $ref: '#/definitions/CertificateDetails' + description: Root certificate + serialNumber: + description: Current serial number of the certificate + type: string + lastCertificateIssuanceTime: + format: date-time + description: Certificate last issuance time + type: string + expirationTime: + format: date-time + description: Certificate expiration time + type: string + x-ms-client-flatten: true + CertificateDetails: + description: Certificate Details + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + version: + format: int32 + description: Version + type: integer + serialNumber: + description: Serial Number + type: string + thumbprint: + description: Thumbprint + type: string + subject: + description: Subject + type: string + notBefore: + format: date-time + description: Valid from + type: string + notAfter: + format: date-time + description: Valid to + type: string + signatureAlgorithm: + description: Signature Algorithm + type: string + issuer: + description: Issuer + type: string + rawData: + description: Raw certificate data + type: string + x-ms-client-flatten: true + CertificateOrderCollection: + description: Collection of ceritificate orders + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/CertificateOrder' + nextLink: + description: Link to next page of resources + type: string + CertificateOrderCertificateCollection: + description: Collection of ceritificateorder certificates + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/CertificateOrderCertificate' + nextLink: + description: Link to next page of resources + type: string + ReissueCertificateOrderRequest: + description: Class representing certificate reissue request + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + keySize: + format: int32 + description: Certificate Key Size + type: integer + delayExistingRevokeInHours: + format: int32 + description: >- + Delay in hours to revoke existing certificate after the new + certificate is issued + type: integer + x-ms-client-flatten: true + RenewCertificateOrderRequest: + description: Class representing certificate renew request + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + keySize: + format: int32 + description: Certificate Key Size + type: integer + x-ms-client-flatten: true + CertificateOrderAction: + description: Represents a certificate action + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - type + properties: + type: + description: Type + enum: + - CertificateIssued + - CertificateOrderCanceled + - CertificateOrderCreated + - CertificateRevoked + - DomainValidationComplete + - FraudDetected + - OrgNameChange + - OrgValidationComplete + - SanDrop + type: string + x-ms-enum: + name: CertificateOrderActionType + modelAsString: false + createdAt: + format: date-time + description: Time at which the certificate action was performed + type: string + x-ms-client-flatten: true + CertificateEmail: + description: Certificate Email + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + emailId: + description: Email id + type: string + timeStamp: + format: date-time + description: Time stamp + type: string + x-ms-client-flatten: true + CertificateCollection: + description: Collection of certificates + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/Certificate' + nextLink: + description: Link to next page of resources + type: string + Certificate: + description: App certificate + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + friendlyName: + description: Friendly name of the certificate + type: string + subjectName: + description: Subject name of the certificate + type: string + hostNames: + description: Host names the certificate applies to + type: array + items: + type: string + pfxBlob: + description: Pfx blob + type: string + siteName: + description: App name + type: string + selfLink: + description: Self link + type: string + issuer: + description: Certificate issuer + type: string + issueDate: + format: date-time + description: Certificate issue Date + type: string + expirationDate: + format: date-time + description: Certificate expriration date + type: string + password: + description: Certificate password + type: string + thumbprint: + description: Certificate thumbprint + type: string + valid: + description: Is the certificate valid? + type: boolean + cerBlob: + description: Raw bytes of .cer file + type: string + publicKeyHash: + description: Public key hash + type: string + hostingEnvironmentProfile: + $ref: '#/definitions/HostingEnvironmentProfile' + description: >- + Specification for the hosting environment (App Service + Environment) to use for the certificate + x-ms-client-flatten: true + HostingEnvironmentProfile: + description: >- + Specification for a hostingEnvironment (App Service Environment) to use + for this resource + type: object + properties: + id: + description: Resource id of the hostingEnvironment (App Service Environment) + type: string + name: + description: Name of the hostingEnvironment (App Service Environment) (read only) + type: string + type: + description: >- + Resource type of the hostingEnvironment (App Service Environment) + (read only) + type: string + Csr: + description: Certificate signing request object + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Name used to locate CSR object + type: string + distinguishedName: + description: Distinguished name of certificate to be created + type: string + csrString: + description: Actual CSR string created + type: string + pfxBlob: + description: PFX certifcate of created certificate + type: string + password: + description: PFX password + type: string + publicKeyHash: + description: Hash of the certificates public key + type: string + hostingEnvironment: + description: Hosting environment + type: string + x-ms-client-flatten: true + ClassicMobileServiceCollection: + description: Collection of Classic Mobile Services + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/ClassicMobileService' + nextLink: + description: Link to next page of resources + type: string + ClassicMobileService: + description: A mobile service + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Name of the mobile service + type: string + x-ms-client-flatten: true + DomainCollection: + description: Collection of domains + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/Domain' + nextLink: + description: Link to next page of resources + type: string + Domain: + description: Represents a domain + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + contactAdmin: + $ref: '#/definitions/Contact' + description: Admin contact information + contactBilling: + $ref: '#/definitions/Contact' + description: Billing contact information + contactRegistrant: + $ref: '#/definitions/Contact' + description: Registrant contact information + contactTech: + $ref: '#/definitions/Contact' + description: Technical contact information + registrationStatus: + description: Domain registration status + enum: + - Active + - Awaiting + - Cancelled + - Confiscated + - Disabled + - Excluded + - Expired + - Failed + - Held + - Locked + - Parked + - Pending + - Reserved + - Reverted + - Suspended + - Transferred + - Unknown + - Unlocked + - Unparked + - Updated + - JsonConverterFailed + type: string + x-ms-enum: + name: DomainStatus + modelAsString: false + provisioningState: + description: Domain provisioning state + enum: + - Succeeded + - Failed + - Canceled + - InProgress + - Deleting + type: string + x-ms-enum: + name: ProvisioningState + modelAsString: false + nameServers: + description: Name servers + type: array + items: + type: string + privacy: + description: If true then domain privacy is enabled for this domain + type: boolean + createdTime: + format: date-time + description: Domain creation timestamp + type: string + expirationTime: + format: date-time + description: Domain expiration timestamp + type: string + lastRenewedTime: + format: date-time + description: Timestamp when the domain was renewed last time + type: string + autoRenew: + description: If true then domain will renewed automatically + type: boolean + readyForDnsRecordManagement: + description: >- + If true then Azure can assign this domain to Web Apps. This value + will be true if domain registration status is active and it is + hosted on name servers Azure has programmatic access to + type: boolean + managedHostNames: + description: >- + All hostnames derived from the domain and assigned to Azure + resources + type: array + items: + $ref: '#/definitions/HostName' + consent: + $ref: '#/definitions/DomainPurchaseConsent' + description: Legal agreement consent + domainNotRenewableReasons: + description: Reasons why domain is not renewable + type: array + items: + enum: + - RegistrationStatusNotSupportedForRenewal + - ExpirationNotInRenewalTimeRange + - SubscriptionNotActive + type: string + x-ms-client-flatten: true + Contact: + description: >- + Contact information for domain registration. If 'Domain Privacy' option is + not selected then the contact information will be be made publicly + available through the Whois directories as per ICANN requirements. + type: object + properties: + addressMailing: + $ref: '#/definitions/Address' + description: Mailing address + email: + description: Email address + type: string + fax: + description: Fax number + type: string + jobTitle: + description: Job title + type: string + nameFirst: + description: First name + type: string + nameLast: + description: Last name + type: string + nameMiddle: + description: Middle name + type: string + organization: + description: Organization + type: string + phone: + description: Phone number + type: string + HostName: + description: Details of a hostname derived from a domain + type: object + properties: + name: + description: Name of the hostname + type: string + siteNames: + description: >- + List of sites the hostname is assigned to. This list will have more + than one site only if the hostname is pointing to a Traffic Manager + type: array + items: + type: string + azureResourceName: + description: >- + Name of the Azure resource the hostname is assigned to. If it is + assigned to a traffic manager then it will be the traffic manager name + otherwise it will be the website name + type: string + azureResourceType: + description: Type of the Azure resource the hostname is assigned to + enum: + - Website + - TrafficManager + type: string + x-ms-enum: + name: AzureResourceType + modelAsString: false + customHostNameDnsRecordType: + description: Type of the Dns record + enum: + - CName + - A + type: string + x-ms-enum: + name: CustomHostNameDnsRecordType + modelAsString: false + hostNameType: + description: Type of the hostname + enum: + - Verified + - Managed + type: string + x-ms-enum: + name: HostNameType + modelAsString: false + DomainPurchaseConsent: + description: >- + Domain purchase consent object representing acceptance of applicable legal + agreements + type: object + properties: + agreementKeys: + description: >- + List of applicable legal agreement keys. This list can be retrieved + using ListLegalAgreements Api under TopLevelDomain resource + type: array + items: + type: string + agreedBy: + description: Client IP address + type: string + agreedAt: + format: date-time + description: Timestamp when the agreements were accepted + type: string + Address: + description: Address information for domain registration + type: object + properties: + address1: + description: Address 1 + type: string + address2: + description: Address 2 + type: string + city: + description: City + type: string + country: + description: Country + type: string + postalCode: + description: Postal code + type: string + state: + description: State + type: string + User: + description: Represents user crendentials used for publishing activity + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Username (internal) + type: string + publishingUserName: + description: Username used for publishing + type: string + publishingPassword: + description: Password used for publishing + type: string + x-ms-client-flatten: true + GeoRegionCollection: + description: Collection of geo regions + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/GeoRegion' + nextLink: + description: Link to next page of resources + type: string + GeoRegion: + description: Geographical region + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Region name + type: string + description: + description: Region description + type: string + displayName: + description: Display name for region + type: string + x-ms-client-flatten: true + ServerFarmCollection: + description: Collection of serverfarms + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/ServerFarmWithRichSku' + nextLink: + description: Link to next page of resources + type: string + ServerFarmWithRichSku: + description: App Service Plan Model + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - status + properties: + name: + description: Name for the App Service Plan + type: string + workerTierName: + description: Target worker tier assigned to the App Service Plan + type: string + status: + description: App Service Plan Status + enum: + - Ready + - Pending + type: string + readOnly: true + x-ms-enum: + name: StatusOptions + modelAsString: false + subscription: + description: App Service Plan Subscription + type: string + readOnly: true + adminSiteName: + description: App Service Plan administration site + type: string + hostingEnvironmentProfile: + $ref: '#/definitions/HostingEnvironmentProfile' + description: >- + Specification for the hosting environment (App Service + Environment) to use for the App Service Plan + maximumNumberOfWorkers: + format: int32 + description: >- + Maximum number of instances that can be assigned to this App + Service Plan + type: integer + geoRegion: + description: Geographical location for the App Service Plan + type: string + readOnly: true + perSiteScaling: + description: "If True apps assigned to this App Service Plan can be scaled independently\r\n If False apps assigned to this App Service Plan will scale to all instances of the plan" + type: boolean + numberOfSites: + format: int32 + description: Number of web apps assigned to this App Service Plan + type: integer + readOnly: true + resourceGroup: + description: Resource group of the serverfarm + type: string + readOnly: true + x-ms-client-flatten: true + sku: + $ref: '#/definitions/SkuDescription' + SiteCollection: + description: Collection of sites + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/Site' + nextLink: + description: Link to next page of resources + type: string + Site: + description: Represents a web app + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - usageState + - availabilityState + properties: + name: + description: Name of web app + type: string + state: + description: State of the web app + type: string + readOnly: true + hostNames: + description: Hostnames associated with web app + type: array + items: + type: string + readOnly: true + repositorySiteName: + description: Name of repository site + type: string + readOnly: true + usageState: + description: State indicating whether web app has exceeded its quota usage + enum: + - Normal + - Exceeded + type: string + readOnly: true + x-ms-enum: + name: UsageState + modelAsString: false + enabled: + description: >- + True if the site is enabled; otherwise, false. Setting this value + to false disables the site (takes the site off line). + type: boolean + enabledHostNames: + description: "Hostnames for the web app that are enabled. Hostnames need to be assigned and enabled. If some hostnames are assigned but not enabled\r\n the app is not served on those hostnames" + type: array + items: + type: string + readOnly: true + availabilityState: + description: "Management information availability state for the web app. Possible values are Normal or Limited. \r\n Normal means that the site is running correctly and that management information for the site is available. \r\n Limited means that only partial management information for the site is available and that detailed site information is unavailable." + enum: + - Normal + - Limited + - DisasterRecoveryMode + type: string + readOnly: true + x-ms-enum: + name: SiteAvailabilityState + modelAsString: false + hostNameSslStates: + description: >- + Hostname SSL states are used to manage the SSL bindings for + site's hostnames. + type: array + items: + $ref: '#/definitions/HostNameSslState' + serverFarmId: + type: string + lastModifiedTimeUtc: + format: date-time + description: Last time web app was modified in UTC + type: string + readOnly: true + siteConfig: + $ref: '#/definitions/SiteConfig' + description: Configuration of web app + trafficManagerHostNames: + description: >- + Read-only list of Azure Traffic manager hostnames associated with + web app + type: array + items: + type: string + readOnly: true + premiumAppDeployed: + description: If set indicates whether web app is deployed as a premium app + type: boolean + readOnly: true + scmSiteAlsoStopped: + description: >- + If set indicates whether to stop SCM (KUDU) site when the web app + is stopped. Default is false. + type: boolean + targetSwapSlot: + description: >- + Read-only property that specifies which slot this app will swap + into + type: string + readOnly: true + hostingEnvironmentProfile: + $ref: '#/definitions/HostingEnvironmentProfile' + description: >- + Specification for the hosting environment (App Service + Environment) to use for the web app + microService: + description: '' + type: string + gatewaySiteName: + description: Name of gateway app associated with web app + type: string + clientAffinityEnabled: + description: >- + Specifies if the client affinity is enabled when load balancing + http request for multiple instances of the web app + type: boolean + clientCertEnabled: + description: Specifies if the client certificate is enabled for the web app + type: boolean + hostNamesDisabled: + description: "Specifies if the public hostnames are disabled the web app.\r\n If set to true the app is only accessible via API Management process" + type: boolean + outboundIpAddresses: + description: >- + List of comma separated IP addresses that this web app uses for + outbound connections. Those can be used when configuring firewall + rules for databases accessed by this web app. + type: string + readOnly: true + containerSize: + format: int32 + description: Size of a function container + type: integer + maxNumberOfWorkers: + format: int32 + description: "Maximum number of workers\r\n This only applies to function container" + type: integer + cloningInfo: + $ref: '#/definitions/CloningInfo' + description: "This is only valid for web app creation. If specified, web app is cloned from \r\n a source web app" + resourceGroup: + description: Resource group web app belongs to + type: string + readOnly: true + isDefaultContainer: + description: Site is a default container + type: boolean + readOnly: true + defaultHostName: + description: Default hostname of the web app + type: string + readOnly: true + x-ms-client-flatten: true + SiteProperties: + type: object + properties: + metadata: + type: array + items: + $ref: '#/definitions/NameValuePair' + properties: + type: array + items: + $ref: '#/definitions/NameValuePair' + appSettings: + type: array + items: + $ref: '#/definitions/NameValuePair' + HostNameSslState: + description: Object that represents a SSL-enabled host name. + required: + - sslState + type: object + properties: + name: + description: Host name + type: string + sslState: + description: SSL type + enum: + - Disabled + - SniEnabled + - IpBasedEnabled + type: string + x-ms-enum: + name: SslState + modelAsString: false + virtualIP: + description: >- + Virtual IP address assigned to the host name if IP based SSL is + enabled + type: string + thumbprint: + description: SSL cert thumbprint + type: string + toUpdate: + description: Set this flag to update existing host name + type: boolean + SiteConfig: + description: Configuration of Azure web site + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + numberOfWorkers: + format: int32 + description: Number of workers + type: integer + defaultDocuments: + description: Default documents + type: array + items: + type: string + netFrameworkVersion: + description: Net Framework Version + type: string + phpVersion: + description: Version of PHP + type: string + pythonVersion: + description: Version of Python + type: string + requestTracingEnabled: + description: Enable request tracing + type: boolean + requestTracingExpirationTime: + format: date-time + description: Request tracing expiration time + type: string + remoteDebuggingEnabled: + description: Remote Debugging Enabled + type: boolean + remoteDebuggingVersion: + description: Remote Debugging Version + type: string + httpLoggingEnabled: + description: HTTP logging Enabled + type: boolean + logsDirectorySizeLimit: + format: int32 + description: HTTP Logs Directory size limit + type: integer + detailedErrorLoggingEnabled: + description: Detailed error logging enabled + type: boolean + publishingUsername: + description: Publishing user name + type: string + publishingPassword: + description: Publishing password + type: string + appSettings: + description: Application Settings + type: array + items: + $ref: '#/definitions/NameValuePair' + metadata: + description: Site Metadata + type: array + items: + $ref: '#/definitions/NameValuePair' + connectionStrings: + description: Connection strings + type: array + items: + $ref: '#/definitions/ConnStringInfo' + handlerMappings: + description: Handler mappings + type: array + items: + $ref: '#/definitions/HandlerMapping' + documentRoot: + description: Document root + type: string + scmType: + description: SCM type + type: string + use32BitWorkerProcess: + description: Use 32 bit worker process + type: boolean + webSocketsEnabled: + description: Web socket enabled. + type: boolean + alwaysOn: + description: Always On + type: boolean + javaVersion: + description: Java version + type: string + javaContainer: + description: Java container + type: string + javaContainerVersion: + description: Java container version + type: string + managedPipelineMode: + description: Managed pipeline mode + enum: + - Integrated + - Classic + type: string + x-ms-enum: + name: ManagedPipelineMode + modelAsString: false + virtualApplications: + description: Virtual applications + type: array + items: + $ref: '#/definitions/VirtualApplication' + loadBalancing: + description: Site load balancing + enum: + - WeightedRoundRobin + - LeastRequests + - LeastResponseTime + - WeightedTotalTraffic + - RequestHash + type: string + x-ms-enum: + name: SiteLoadBalancing + modelAsString: false + experiments: + $ref: '#/definitions/Experiments' + description: This is work around for polymophic types + limits: + $ref: '#/definitions/SiteLimits' + description: Site limits + autoHealEnabled: + description: Auto heal enabled + type: boolean + autoHealRules: + $ref: '#/definitions/AutoHealRules' + description: Auto heal rules + tracingOptions: + description: Tracing options + type: string + vnetName: + description: Vnet name + type: string + cors: + $ref: '#/definitions/CorsSettings' + description: Cross-Origin Resource Sharing (CORS) settings. + apiDefinition: + $ref: '#/definitions/ApiDefinitionInfo' + description: Information about the formal API definition for the web app. + autoSwapSlotName: + description: Auto swap slot name + type: string + localMySqlEnabled: + description: Local mysql enabled + type: boolean + ipSecurityRestrictions: + description: Ip Security restrictions + type: array + items: + $ref: '#/definitions/IpSecurityRestriction' + x-ms-client-flatten: true + CloningInfo: + description: Represents information needed for cloning operation + type: object + properties: + correlationId: + description: "Correlation Id of cloning operation. This id ties multiple cloning operations\r\n together to use the same snapshot" + type: string + overwrite: + description: Overwrite destination web app + type: boolean + cloneCustomHostNames: + description: 'If true, clone custom hostnames from source web app' + type: boolean + cloneSourceControl: + description: Clone source control from source web app + type: boolean + sourceWebAppId: + description: "ARM resource id of the source web app. Web app resource id is of the form \r\n /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName} for production slots and \r\n /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/slots/{slotName} for other slots" + type: string + hostingEnvironment: + description: Hosting environment + type: string + appSettingsOverrides: + description: "Application settings overrides for cloned web app. If specified these settings will override the settings cloned \r\n from source web app. If not specified, application settings from source web app are retained." + type: object + additionalProperties: + type: string + configureLoadBalancing: + description: If specified configure load balancing for source and clone site + type: boolean + trafficManagerProfileId: + description: "ARM resource id of the traffic manager profile to use if it exists. Traffic manager resource id is of the form \r\n /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{profileName}" + type: string + trafficManagerProfileName: + description: >- + Name of traffic manager profile to create. This is only needed if + traffic manager profile does not already exist + type: string + NameValuePair: + description: Name value pair + type: object + properties: + name: + description: Pair name + type: string + value: + description: Pair value + type: string + ConnStringInfo: + description: Represents database connection string information + required: + - type + type: object + properties: + name: + description: Name of connection string + type: string + connectionString: + description: Connection string value + type: string + type: + description: Type of database + enum: + - MySql + - SQLServer + - SQLAzure + - Custom + type: string + x-ms-enum: + name: DatabaseServerType + modelAsString: false + HandlerMapping: + description: "The IIS handler mappings used to define which handler processes HTTP requests with certain extension. \r\n For example it is used to configure php-cgi.exe process to handle all HTTP requests with *.php extension." + type: object + properties: + extension: + description: >- + Requests with this extension will be handled using the specified + FastCGI application. + type: string + scriptProcessor: + description: The absolute path to the FastCGI application. + type: string + arguments: + description: Command-line arguments to be passed to the script processor. + type: string + VirtualApplication: + type: object + properties: + virtualPath: + type: string + physicalPath: + type: string + preloadEnabled: + type: boolean + virtualDirectories: + type: array + items: + $ref: '#/definitions/VirtualDirectory' + RoutingRule: + description: Routing rules for TiP + type: object + properties: + name: + description: >- + Name of the routing rule. The recommended name would be to point to + the slot which will receive the traffic in the experiment. + type: string + Experiments: + description: Class containing Routing in production experiments + type: object + properties: + rampUpRules: + description: 'List of {Microsoft.Web.Hosting.Administration.RampUpRule} objects.' + type: array + items: + $ref: '#/definitions/RampUpRule' + SiteLimits: + description: Represents metric limits set on a web app. + type: object + properties: + maxPercentageCpu: + format: double + description: Maximum allowed CPU usage percentage + type: number + maxMemoryInMb: + format: int64 + description: Maximum allowed memory usage in MB + type: integer + maxDiskSizeInMb: + format: int64 + description: Maximum allowed disk size usage in MB + type: integer + AutoHealRules: + description: AutoHealRules - describes the rules which can be defined for auto-heal + type: object + properties: + triggers: + $ref: '#/definitions/AutoHealTriggers' + description: >- + Triggers - Conditions that describe when to execute the auto-heal + actions + actions: + $ref: '#/definitions/AutoHealActions' + description: Actions - Actions to be executed when a rule is triggered + SiteAuthSettings: + description: >- + Configuration settings for the Azure App Service Authentication / + Authorization feature. + type: object + properties: + enabled: + description: >- + Gets or sets a value indicating whether the Authentication / + Authorization feature is enabled for the current app. + type: boolean + httpApiPrefixPath: + description: "Gets or sets the relative path prefix used by platform HTTP APIs.\r\n Changing this value is not recommended except for compatibility reasons." + type: string + unauthenticatedClientAction: + description: >- + Gets or sets the action to take when an unauthenticated client + attempts to access the app. + enum: + - RedirectToLoginPage + - AllowAnonymous + type: string + x-ms-enum: + name: UnauthenticatedClientAction + modelAsString: false + tokenStoreEnabled: + description: "Gets or sets a value indicating whether to durably store platform-specific security tokens\r\n obtained during login flows. This capability is disabled by default." + type: boolean + allowedExternalRedirectUrls: + description: "Gets or sets a collection of external URLs that can be redirected to as part of logging in\r\n or logging out of the web app. Note that the query string part of the URL is ignored.\r\n This is an advanced setting typically only needed by Windows Store application backends.\r\n Note that URLs within the current domain are always implicitly allowed." + type: array + items: + type: string + defaultProvider: + description: "Gets or sets the default authentication provider to use when multiple providers are configured.\r\n This setting is only needed if multiple providers are configured and the unauthenticated client\r\n action is set to \"RedirectToLoginPage\"." + enum: + - AzureActiveDirectory + - Facebook + - Google + - MicrosoftAccount + - Twitter + type: string + x-ms-enum: + name: BuiltInAuthenticationProvider + modelAsString: false + tokenRefreshExtensionHours: + format: double + description: "Gets or sets the number of hours after session token expiration that a session token can be used to\r\n call the token refresh API. The default is 72 hours." + type: number + clientId: + description: "Gets or sets the Client ID of this relying party application, known as the client_id.\r\n This setting is required for enabling OpenID Connection authentication with Azure Active Directory or \r\n other 3rd party OpenID Connect providers.\r\n More information on OpenID Connect: http://openid.net/specs/openid-connect-core-1_0.html" + type: string + clientSecret: + description: "Gets or sets the Client Secret of this relying party application (in Azure Active Directory, this is also referred to as the Key).\r\n This setting is optional. If no client secret is configured, the OpenID Connect implicit auth flow is used to authenticate end users.\r\n Otherwise, the OpenID Connect Authorization Code Flow is used to authenticate end users.\r\n More information on OpenID Connect: http://openid.net/specs/openid-connect-core-1_0.html" + type: string + issuer: + description: "Gets or sets the OpenID Connect Issuer URI that represents the entity which issues access tokens for this application.\r\n When using Azure Active Directory, this value is the URI of the directory tenant, e.g. https://sts.windows.net/{tenant-guid}/.\r\n This URI is a case-sensitive identifier for the token issuer.\r\n More information on OpenID Connect Discovery: http://openid.net/specs/openid-connect-discovery-1_0.html" + type: string + allowedAudiences: + description: "Gets or sets a list of allowed audience values to consider when validating JWTs issued by \r\n Azure Active Directory. Note that the {Microsoft.Web.Hosting.Administration.SiteAuthSettings.ClientId} value is always considered an\r\n allowed audience, regardless of this setting." + type: array + items: + type: string + additionalLoginParams: + description: "Gets or sets a list of login parameters to send to the OpenID Connect authorization endpoint when\r\n a user logs in. Each parameter must be in the form \"key=value\"." + type: array + items: + type: string + aadClientId: + type: string + openIdIssuer: + type: string + googleClientId: + description: "Gets or sets the OpenID Connect Client ID for the Google web application.\r\n This setting is required for enabling Google Sign-In.\r\n Google Sign-In documentation: https://developers.google.com/identity/sign-in/web/" + type: string + googleClientSecret: + description: "Gets or sets the client secret associated with the Google web application.\r\n This setting is required for enabling Google Sign-In.\r\n Google Sign-In documentation: https://developers.google.com/identity/sign-in/web/" + type: string + googleOAuthScopes: + description: "Gets or sets the OAuth 2.0 scopes that will be requested as part of Google Sign-In authentication.\r\n This setting is optional. If not specified, \"openid\", \"profile\", and \"email\" are used as default scopes.\r\n Google Sign-In documentation: https://developers.google.com/identity/sign-in/web/" + type: array + items: + type: string + facebookAppId: + description: "Gets or sets the App ID of the Facebook app used for login.\r\n This setting is required for enabling Facebook Login.\r\n Facebook Login documentation: https://developers.facebook.com/docs/facebook-login" + type: string + facebookAppSecret: + description: "Gets or sets the App Secret of the Facebook app used for Facebook Login.\r\n This setting is required for enabling Facebook Login.\r\n Facebook Login documentation: https://developers.facebook.com/docs/facebook-login" + type: string + facebookOAuthScopes: + description: "Gets or sets the OAuth 2.0 scopes that will be requested as part of Facebook Login authentication.\r\n This setting is optional.\r\n Facebook Login documentation: https://developers.facebook.com/docs/facebook-login" + type: array + items: + type: string + twitterConsumerKey: + description: "Gets or sets the OAuth 1.0a consumer key of the Twitter application used for sign-in.\r\n This setting is required for enabling Twitter Sign-In.\r\n Twitter Sign-In documentation: https://dev.twitter.com/web/sign-in" + type: string + twitterConsumerSecret: + description: "Gets or sets the OAuth 1.0a consumer secret of the Twitter application used for sign-in.\r\n This setting is required for enabling Twitter Sign-In.\r\n Twitter Sign-In documentation: https://dev.twitter.com/web/sign-in" + type: string + microsoftAccountClientId: + description: "Gets or sets the OAuth 2.0 client ID that was created for the app used for authentication.\r\n This setting is required for enabling Microsoft Account authentication.\r\n Microsoft Account OAuth documentation: https://dev.onedrive.com/auth/msa_oauth.htm" + type: string + microsoftAccountClientSecret: + description: "Gets or sets the OAuth 2.0 client secret that was created for the app used for authentication.\r\n This setting is required for enabling Microsoft Account authentication.\r\n Microsoft Account OAuth documentation: https://dev.onedrive.com/auth/msa_oauth.htm" + type: string + microsoftAccountOAuthScopes: + description: "Gets or sets the OAuth 2.0 scopes that will be requested as part of Microsoft Account authentication.\r\n This setting is optional. If not specified, \"wl.basic\" is used as the default scope.\r\n Microsoft Account Scopes and permissions documentation: https://msdn.microsoft.com/en-us/library/dn631845.aspx" + type: array + items: + type: string + CorsSettings: + description: Cross-Origin Resource Sharing (CORS) settings for the web app. + type: object + properties: + allowedOrigins: + description: "Gets or sets the list of origins that should be allowed to make cross-origin\r\n calls (for example: http://example.com:12345). Use \"*\" to allow all." + type: array + items: + type: string + ApiDefinitionInfo: + description: Information about the formal API definition for the web app. + type: object + properties: + url: + description: The URL of the API definition. + type: string + IpSecurityRestriction: + description: Represents an ip security restriction on a web app. + type: object + properties: + ipAddress: + description: IP address the security restriction is valid for + type: string + subnetMask: + description: Subnet mask for the range of IP addresses the restriction is valid for + type: string + VirtualDirectory: + type: object + properties: + virtualPath: + type: string + physicalPath: + type: string + RampUpRule: + description: >- + Routing rules for ramp up testing. This rule allows to redirect static + traffic % to a slot or to gradually change routing % based on performance + type: object + properties: + actionHostName: + description: >- + Hostname of a slot to which the traffic will be redirected if decided + to. E.g. mysite-stage.azurewebsites.net + type: string + reroutePercentage: + format: double + description: >- + Percentage of the traffic which will be redirected to + {Microsoft.Web.Hosting.Administration.RampUpRule.ActionHostName} + type: number + changeStep: + format: double + description: "[Optional] In auto ramp up scenario this is the step to to add/remove from {Microsoft.Web.Hosting.Administration.RampUpRule.ReroutePercentage} until it reaches \r\n {Microsoft.Web.Hosting.Administration.RampUpRule.MinReroutePercentage} or {Microsoft.Web.Hosting.Administration.RampUpRule.MaxReroutePercentage}. Site metrics are checked every N minutes specificed in {Microsoft.Web.Hosting.Administration.RampUpRule.ChangeIntervalInMinutes}.\r\n Custom decision algorithm can be provided in TiPCallback site extension which Url can be specified in {Microsoft.Web.Hosting.Administration.RampUpRule.ChangeDecisionCallbackUrl}" + type: number + changeIntervalInMinutes: + format: int32 + description: >- + [Optional] Specifies interval in mimuntes to reevaluate + ReroutePercentage + type: integer + minReroutePercentage: + format: double + description: >- + [Optional] Specifies lower boundary above which ReroutePercentage will + stay. + type: number + maxReroutePercentage: + format: double + description: >- + [Optional] Specifies upper boundary below which ReroutePercentage will + stay. + type: number + changeDecisionCallbackUrl: + description: "Custom decision algorithm can be provided in TiPCallback site extension which Url can be specified. See TiPCallback site extension for the scaffold and contracts.\r\n https://www.siteextensions.net/packages/TiPCallback/" + type: string + name: + description: >- + Name of the routing rule. The recommended name would be to point to + the slot which will receive the traffic in the experiment. + type: string + AutoHealTriggers: + description: AutoHealTriggers - describes the triggers for auto-heal. + type: object + properties: + requests: + $ref: '#/definitions/RequestsBasedTrigger' + description: Requests - Defines a rule based on total requests + privateBytesInKB: + format: int32 + description: PrivateBytesInKB - Defines a rule based on private bytes + type: integer + statusCodes: + description: StatusCodes - Defines a rule based on status codes + type: array + items: + $ref: '#/definitions/StatusCodesBasedTrigger' + slowRequests: + $ref: '#/definitions/SlowRequestsBasedTrigger' + description: SlowRequests - Defines a rule based on request execution time + AutoHealActions: + description: "AutoHealActions - Describes the actions which can be\r\n taken by the auto-heal module when a rule is triggered." + required: + - actionType + type: object + properties: + actionType: + description: ActionType - predefined action to be taken + enum: + - Recycle + - LogEvent + - CustomAction + type: string + x-ms-enum: + name: AutoHealActionType + modelAsString: false + customAction: + $ref: '#/definitions/AutoHealCustomAction' + description: CustomAction - custom action to be taken + minProcessExecutionTime: + description: "MinProcessExecutionTime - minimum time the process must execute\r\n before taking the action" + type: string + RequestsBasedTrigger: + description: RequestsBasedTrigger + type: object + properties: + count: + format: int32 + description: Count + type: integer + timeInterval: + description: TimeInterval + type: string + StatusCodesBasedTrigger: + description: StatusCodeBasedTrigger + type: object + properties: + status: + format: int32 + description: HTTP status code + type: integer + subStatus: + format: int32 + description: SubStatus + type: integer + win32Status: + format: int32 + description: Win32 error code + type: integer + count: + format: int32 + description: Count + type: integer + timeInterval: + description: TimeInterval + type: string + SlowRequestsBasedTrigger: + description: SlowRequestsBasedTrigger + type: object + properties: + timeTaken: + description: TimeTaken + type: string + count: + format: int32 + description: Count + type: integer + timeInterval: + description: TimeInterval + type: string + AutoHealCustomAction: + description: "AutoHealCustomAction - Describes the custom action to be executed\r\n when an auto heal rule is triggered." + type: object + properties: + exe: + description: Executable to be run + type: string + parameters: + description: Parameters for the executable + type: string + HostingEnvironmentCollection: + description: Collection of hosting environments (App Service Environments) + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/HostingEnvironment' + nextLink: + description: Link to next page of resources + type: string + HostingEnvironment: + description: Description of an hostingEnvironment (App Service Environment) + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - status + properties: + name: + description: Name of the hostingEnvironment (App Service Environment) + type: string + location: + description: >- + Location of the hostingEnvironment (App Service Environment), e.g. + "West US" + type: string + provisioningState: + description: >- + Provisioning state of the hostingEnvironment (App Service + Environment) + enum: + - Succeeded + - Failed + - Canceled + - InProgress + - Deleting + type: string + x-ms-enum: + name: ProvisioningState + modelAsString: false + status: + description: Current status of the hostingEnvironment (App Service Environment) + enum: + - Preparing + - Ready + - Scaling + - Deleting + type: string + x-ms-enum: + name: HostingEnvironmentStatus + modelAsString: false + vnetName: + description: >- + Name of the hostingEnvironment's (App Service Environment) virtual + network + type: string + vnetResourceGroupName: + description: >- + Resource group of the hostingEnvironment's (App Service + Environment) virtual network + type: string + vnetSubnetName: + description: >- + Subnet of the hostingEnvironment's (App Service Environment) + virtual network + type: string + virtualNetwork: + $ref: '#/definitions/VirtualNetworkProfile' + description: >- + Description of the hostingEnvironment's (App Service Environment) + virtual network + internalLoadBalancingMode: + description: >- + Specifies which endpoints to serve internally in the + hostingEnvironment's (App Service Environment) VNET + enum: + - None + - Web + - Publishing + type: string + x-ms-enum: + name: InternalLoadBalancingMode + modelAsString: false + multiSize: + description: 'Front-end VM size, e.g. "Medium", "Large"' + type: string + multiRoleCount: + format: int32 + description: Number of front-end instances + type: integer + workerPools: + description: >- + Description of worker pools with worker size ids, VM sizes, and + number of workers in each pool + type: array + items: + $ref: '#/definitions/WorkerPool' + ipsslAddressCount: + format: int32 + description: >- + Number of IP SSL addresses reserved for this hostingEnvironment + (App Service Environment) + type: integer + databaseEdition: + description: >- + Edition of the metadata database for the hostingEnvironment (App + Service Environment) e.g. "Standard" + type: string + databaseServiceObjective: + description: >- + Service objective of the metadata database for the + hostingEnvironment (App Service Environment) e.g. "S0" + type: string + upgradeDomains: + format: int32 + description: >- + Number of upgrade domains of this hostingEnvironment (App Service + Environment) + type: integer + subscriptionId: + description: Subscription of the hostingEnvironment (App Service Environment) + type: string + dnsSuffix: + description: DNS suffix of the hostingEnvironment (App Service Environment) + type: string + lastAction: + description: >- + Last deployment action on this hostingEnvironment (App Service + Environment) + type: string + lastActionResult: + description: >- + Result of the last deployment action on this hostingEnvironment + (App Service Environment) + type: string + allowedMultiSizes: + description: >- + List of comma separated strings describing which VM sizes are + allowed for front-ends + type: string + allowedWorkerSizes: + description: >- + List of comma separated strings describing which VM sizes are + allowed for workers + type: string + maximumNumberOfMachines: + format: int32 + description: >- + Maximum number of VMs in this hostingEnvironment (App Service + Environment) + type: integer + vipMappings: + description: >- + Description of IP SSL mapping for this hostingEnvironment (App + Service Environment) + type: array + items: + $ref: '#/definitions/VirtualIPMapping' + environmentCapacities: + description: 'Current total, used, and available worker capacities' + type: array + items: + $ref: '#/definitions/StampCapacity' + networkAccessControlList: + description: >- + Access control list for controlling traffic to the + hostingEnvironment (App Service Environment) + type: array + items: + $ref: '#/definitions/NetworkAccessControlEntry' + environmentIsHealthy: + description: >- + True/false indicating whether the hostingEnvironment (App Service + Environment) is healthy + type: boolean + environmentStatus: + description: >- + Detailed message about with results of the last check of the + hostingEnvironment (App Service Environment) + type: string + resourceGroup: + description: Resource group of the hostingEnvironment (App Service Environment) + type: string + apiManagementAccountId: + description: Api Management Account associated with this Hosting Environment + type: string + suspended: + description: "True/false indicating whether the hostingEnvironment is suspended. The environment can be suspended e.g. when the management endpoint is no longer available\r\n (most likely because NSG blocked the incoming traffic)" + type: boolean + clusterSettings: + description: >- + Custom settings for changing the behavior of the hosting + environment + type: array + items: + $ref: '#/definitions/NameValuePair' + x-ms-client-flatten: true + VirtualNetworkProfile: + description: Specification for using a virtual network + type: object + properties: + id: + description: Resource id of the virtual network + type: string + name: + description: Name of the virtual network (read-only) + type: string + type: + description: Resource type of the virtual network (read-only) + type: string + subnet: + description: Subnet within the virtual network + type: string + WorkerPool: + description: Worker pool of a hostingEnvironment (App Service Environment) + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + workerSizeId: + format: int32 + description: Worker size id for referencing this worker pool + type: integer + computeMode: + description: Shared or dedicated web app hosting + enum: + - Shared + - Dedicated + - Dynamic + type: string + x-ms-enum: + name: ComputeModeOptions + modelAsString: false + workerSize: + description: VM size of the worker pool instances + type: string + workerCount: + format: int32 + description: Number of instances in the worker pool + type: integer + instanceNames: + description: Names of all instances in the worker pool (read only) + type: array + items: + type: string + x-ms-client-flatten: true + sku: + $ref: '#/definitions/SkuDescription' + VirtualIPMapping: + description: Class that represents a VIP mapping + type: object + properties: + virtualIP: + description: Virtual IP address + type: string + internalHttpPort: + format: int32 + description: Internal HTTP port + type: integer + internalHttpsPort: + format: int32 + description: Internal HTTPS port + type: integer + inUse: + description: Is VIP mapping in use + type: boolean + StampCapacity: + description: Class containing stamp capacity information + type: object + properties: + name: + description: Name of the stamp + type: string + availableCapacity: + format: int64 + description: 'Available capacity (# of machines, bytes of storage etc...)' + type: integer + totalCapacity: + format: int64 + description: 'Total capacity (# of machines, bytes of storage etc...)' + type: integer + unit: + description: Name of the unit + type: string + computeMode: + description: Shared/Dedicated workers + enum: + - Shared + - Dedicated + - Dynamic + type: string + x-ms-enum: + name: ComputeModeOptions + modelAsString: false + workerSize: + description: Size of the machines + enum: + - Default + - Small + - Medium + - Large + type: string + x-ms-enum: + name: WorkerSizeOptions + modelAsString: false + workerSizeId: + format: int32 + description: "Size Id of machines: \r\n 0 - Small\r\n 1 - Medium\r\n 2 - Large" + type: integer + excludeFromCapacityAllocation: + description: "If true it includes basic sites\r\n Basic sites are not used for capacity allocation." + type: boolean + isApplicableForAllComputeModes: + description: Is capacity applicable for all sites? + type: boolean + siteMode: + description: Shared or Dedicated + type: string + NetworkAccessControlEntry: + type: object + properties: + action: + enum: + - Permit + - Deny + type: string + x-ms-enum: + name: AccessControlEntryAction + modelAsString: false + description: + type: string + order: + format: int32 + type: integer + remoteSubnet: + type: string + ManagedHostingEnvironmentCollection: + description: Collection of managed hosting environments + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/ManagedHostingEnvironment' + nextLink: + description: Link to next page of resources + type: string + ManagedHostingEnvironment: + description: Description of a managed hosting environment + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - status + properties: + name: + description: Name of the managed hosting environment + type: string + location: + description: Location of the managed hosting environment e.g. "West US" + type: string + status: + description: Current status of the managed hosting environment + enum: + - Preparing + - Ready + - Deleting + type: string + x-ms-enum: + name: ManagedHostingEnvironmentStatus + modelAsString: false + virtualNetwork: + $ref: '#/definitions/VirtualNetworkProfile' + description: Description of the managed hosting environment's virtual network + ipsslAddressCount: + format: int32 + description: >- + Number of ip ssl addresses reserved for the managed hosting + environment + type: integer + dnsSuffix: + description: DNS suffix of the managed hosting environment + type: string + subscriptionId: + description: Subscription of the managed hosting environment (read only) + type: string + resourceGroup: + description: Resource group of the managed hosting environment (read only) + type: string + environmentIsHealthy: + description: >- + True/false indicating whether the managed hosting environment is + healthy + type: boolean + environmentStatus: + description: >- + Detailed message about with results of the last check of the + managed hosting environment + type: string + suspended: + description: "True/false indicating whether the managed hosting environment is suspended. The environment can be suspended e.g. when the management endpoint is no longer available\r\n (most likely because NSG blocked the incoming traffic)" + type: boolean + apiManagementAccount: + description: >- + Resource id of the api management account associated with this + managed hosting environment (read only) + type: string + x-ms-client-flatten: true + ResourceNameAvailabilityRequest: + description: Resource name availability request content + type: object + properties: + name: + description: Resource name to verify + type: string + type: + description: Resource type used for verification + type: string + isFqdn: + description: Is fully qualified domain name + type: boolean + ResourceNameAvailability: + description: Describes if a resource name is available + type: object + properties: + nameAvailable: + description: >- + True indicates name is valid and available. False indicates the name + is invalid, unavailable, or both. + type: boolean + reason: + description: >- + Required if nameAvailable is false. 'Invalid' indicates the name + provided does not match Azure WebApp service’s naming requirements. + 'AlreadyExists' indicates that the name is already in use and is + therefore unavailable. + type: string + message: + type: string + DomainControlCenterSsoRequest: + description: Single sign on request information for domain management + type: object + properties: + url: + description: Url where the single sign on request is to be made + type: string + postParameterKey: + description: Post parameter key + type: string + postParameterValue: + description: >- + Post parameter value. Client should use + 'application/x-www-form-urlencoded' encoding for this value. + type: string + DomainRegistrationInput: + description: Domain registration input for validation Api + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Name of the domain + type: string + contactAdmin: + $ref: '#/definitions/Contact' + description: Admin contact information + contactBilling: + $ref: '#/definitions/Contact' + description: Billing contact information + contactRegistrant: + $ref: '#/definitions/Contact' + description: Registrant contact information + contactTech: + $ref: '#/definitions/Contact' + description: Technical contact information + registrationStatus: + description: Domain registration status + enum: + - Active + - Awaiting + - Cancelled + - Confiscated + - Disabled + - Excluded + - Expired + - Failed + - Held + - Locked + - Parked + - Pending + - Reserved + - Reverted + - Suspended + - Transferred + - Unknown + - Unlocked + - Unparked + - Updated + - JsonConverterFailed + type: string + x-ms-enum: + name: DomainStatus + modelAsString: false + provisioningState: + description: Domain provisioning state + enum: + - Succeeded + - Failed + - Canceled + - InProgress + - Deleting + type: string + x-ms-enum: + name: ProvisioningState + modelAsString: false + nameServers: + description: Name servers + type: array + items: + type: string + privacy: + description: If true then domain privacy is enabled for this domain + type: boolean + createdTime: + format: date-time + description: Domain creation timestamp + type: string + expirationTime: + format: date-time + description: Domain expiration timestamp + type: string + lastRenewedTime: + format: date-time + description: Timestamp when the domain was renewed last time + type: string + autoRenew: + description: If true then domain will renewed automatically + type: boolean + readyForDnsRecordManagement: + description: >- + If true then Azure can assign this domain to Web Apps. This value + will be true if domain registration status is active and it is + hosted on name servers Azure has programmatic access to + type: boolean + managedHostNames: + description: >- + All hostnames derived from the domain and assigned to Azure + resources + type: array + items: + $ref: '#/definitions/HostName' + consent: + $ref: '#/definitions/DomainPurchaseConsent' + description: Legal agreement consent + domainNotRenewableReasons: + description: Reasons why domain is not renewable + type: array + items: + enum: + - RegistrationStatusNotSupportedForRenewal + - ExpirationNotInRenewalTimeRange + - SubscriptionNotActive + type: string + x-ms-client-flatten: true + NameIdentifier: + description: Identifies an object + type: object + properties: + name: + description: Name of the object + type: string + DomainAvailablilityCheckResult: + description: Domain availablility check result + type: object + properties: + name: + description: Name of the domain + type: string + available: + description: If true then domain can be purchased using CreateDomain Api + type: boolean + domainType: + description: Domain type + enum: + - Regular + - SoftDeleted + type: string + x-ms-enum: + name: DomainType + modelAsString: false + DomainRecommendationSearchParameters: + description: Domain recommendation search parameters + type: object + properties: + keywords: + description: Keywords to be used for generating domain recommendations + type: string + maxDomainRecommendations: + format: int32 + description: Maximum number of recommendations + type: integer + NameIdentifierCollection: + description: Collection of domain name identifiers + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/NameIdentifier' + nextLink: + description: Link to next page of resources + type: string + CsmMoveResourceEnvelope: + description: >- + Class containing a list of the resources that need to be moved and the + resource group they should be moved to + type: object + properties: + targetResourceGroup: + type: string + resources: + type: array + items: + type: string + HostingEnvironmentDiagnostics: + description: Diagnostics for a hosting environment (App Service Environment) + type: object + properties: + name: + description: Name/identifier of the diagnostics + type: string + diagnosicsOutput: + description: Diagnostics output + type: string + StampCapacityCollection: + description: Collection of stamp capacities + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/StampCapacity' + nextLink: + description: Link to next page of resources + type: string + AddressResponse: + description: Describes main public ip address and any extra vips + type: object + properties: + serviceIpAddress: + description: Main public vip + type: string + internalIpAddress: + description: >- + VNET internal ip address of the hostingEnvironment (App Service + Environment) if it is in internal load-balancing mode + type: string + outboundIpAddresses: + description: IP addresses appearing on outbound connections + type: array + items: + type: string + vipMappings: + description: Additional vips + type: array + items: + $ref: '#/definitions/VirtualIPMapping' + ResourceMetricCollection: + description: Collection of metric responses + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/ResourceMetric' + nextLink: + description: Link to next page of resources + type: string + ResourceMetric: + description: Object representing a metric for any resource + type: object + properties: + name: + $ref: '#/definitions/ResourceMetricName' + description: Name of metric + unit: + description: Metric unit + type: string + timeGrain: + description: 'Metric granularity. E.g PT1H, PT5M, P1D' + type: string + startTime: + format: date-time + description: Metric start time + type: string + endTime: + format: date-time + description: Metric end time + type: string + resourceId: + description: Metric resource Id + type: string + metricValues: + description: Metric values + type: array + items: + $ref: '#/definitions/ResourceMetricValue' + properties: + description: Properties + type: array + items: + $ref: '#/definitions/KeyValuePair[String,String]' + ResourceMetricName: + description: Name of a metric for any resource + type: object + properties: + value: + description: metric name value + type: string + localizedValue: + description: Localized metric name value + type: string + ResourceMetricValue: + description: Value of resource metric + type: object + properties: + timeStamp: + description: Value timestamp + type: string + average: + format: float + description: Value average + type: number + minimum: + format: float + description: Value minimum + type: number + maximum: + format: float + description: Value maximum + type: number + total: + format: float + description: Value total + type: number + count: + format: float + description: Value count + type: number + 'KeyValuePair[String,String]': + type: object + properties: + key: + type: string + readOnly: true + value: + type: string + readOnly: true + MetricDefinition: + description: Class repesenting metadata for the metrics + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Name of the metric + type: string + unit: + description: Unit of the metric + type: string + primaryAggregationType: + description: Primary aggregation type + type: string + metricAvailabilities: + description: >- + List of time grains supported for the metric together with + retention period + type: array + items: + $ref: '#/definitions/MetricAvailabilily' + displayName: + description: Friendly name shown in the UI + type: string + x-ms-client-flatten: true + MetricAvailabilily: + description: Class repesenting metrics availability and retention + type: object + properties: + timeGrain: + description: Time grain + type: string + retention: + description: >- + Retention period for the current + {Microsoft.Web.Hosting.Administration.MetricAvailabilily.TimeGrain} + type: string + CsmUsageQuotaCollection: + description: Collection of csm usage quotas + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/CsmUsageQuota' + nextLink: + description: Link to next page of resources + type: string + CsmUsageQuota: + description: Usage of the quota resource + type: object + properties: + unit: + description: Units of measurement for the quota resourse + type: string + nextResetTime: + format: date-time + description: Next reset time for the resource counter + type: string + currentValue: + format: int64 + description: The current value of the resource counter + type: integer + limit: + format: int64 + description: The resource limit + type: integer + name: + $ref: '#/definitions/LocalizableString' + description: Quota name + LocalizableString: + description: LocalizableString object containing the name and a localized value. + type: object + properties: + value: + description: Non localized name + type: string + localizedValue: + description: Localized name + type: string + MetricDefinitionCollection: + description: Collection of metric defintions + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/MetricDefinition' + nextLink: + description: Link to next page of resources + type: string + UsageCollection: + description: Collection of usages + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/Usage' + nextLink: + description: Link to next page of resources + type: string + Usage: + description: Class that represents usage of the quota resource. + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + displayName: + description: Friendly name shown in the UI + type: string + name: + description: Name of the quota + type: string + resourceName: + description: Name of the quota resource + type: string + unit: + description: Units of measurement for the quota resource + type: string + currentValue: + format: int64 + description: The current value of the resource counter + type: integer + limit: + format: int64 + description: The resource limit + type: integer + nextResetTime: + format: date-time + description: Next reset time for the resource counter + type: string + computeMode: + description: ComputeMode used for this usage + enum: + - Shared + - Dedicated + - Dynamic + type: string + x-ms-enum: + name: ComputeModeOptions + modelAsString: false + siteMode: + description: SiteMode used for this usage + type: string + x-ms-client-flatten: true + WorkerPoolCollection: + description: Collection of worker pools + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/WorkerPool' + nextLink: + description: Link to next page of resources + type: string + SkuInfoCollection: + description: Collection of SkuInfos + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/SkuInfo' + nextLink: + description: Link to next page of resources + type: string + SkuInfo: + description: Sku discovery information + type: object + properties: + resourceType: + description: Resource type that this sku applies to + type: string + sku: + $ref: '#/definitions/SkuDescription' + description: Name and tier of the sku + capacity: + $ref: '#/definitions/SkuCapacity' + description: 'Min, max, and default scale values of the sku' + SkuCapacity: + description: Description of the App Service Plan scale options + type: object + properties: + minimum: + format: int32 + description: Minimum number of Workers for this App Service Plan SKU + type: integer + maximum: + format: int32 + description: Maximum number of Workers for this App Service Plan SKU + type: integer + default: + format: int32 + description: Default number of Workers for this App Service Plan SKU + type: integer + scaleType: + description: Available scale configurations for an App Service Plan + type: string + SourceControlCollection: + description: Collection of soure controls + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/SourceControl' + nextLink: + description: Link to next page of resources + type: string + SourceControl: + description: Describes the Source Control OAuth Token + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Name or Source Control Type + type: string + token: + description: OAuth Access Token + type: string + tokenSecret: + description: OAuth Access Token Secret + type: string + refreshToken: + description: OAuth Refresh Token + type: string + expirationTime: + format: date-time + description: OAuth Token Expiration + type: string + x-ms-client-flatten: true + Recommendation: + description: Represents a recommendation result generated by the recommendation engine + required: + - level + - channels + type: object + properties: + creationTime: + format: date-time + description: Timestamp when this instance was created. + type: string + recommendationId: + description: A GUID value that each recommendation object is associated with. + type: string + resourceId: + description: >- + Full ARM resource ID string that this recommendation object is + associated with. + type: string + resourceScope: + description: >- + Name of a resource type this recommendation applies, e.g. + Subscription, ServerFarm, Site. + type: string + ruleName: + description: Unique name of the rule + type: string + displayName: + description: UI friendly name of the rule (may not be unique) + type: string + message: + description: 'Localized text of recommendation, good for UI.' + type: string + level: + description: Level indicating how critical this recommendation can impact. + enum: + - Critical + - Warning + - Information + - NonUrgentSuggestion + type: string + x-ms-enum: + name: NotificationLevel + modelAsString: false + channels: + description: List of channels that this recommendation can apply. + enum: + - Notification + - Api + - Email + - All + type: string + x-ms-enum: + name: Channels + modelAsString: false + tags: + description: The list of category tags that this recommendation belongs to. + type: array + items: + type: string + actionName: + description: Name of action recommended by this object. + type: string + enabled: + format: int32 + description: On/off flag indicating the rule is currently enabled or disabled. + type: integer + startTime: + format: date-time + description: The beginning time of a range that the recommendation refers to. + type: string + endTime: + format: date-time + description: The end time of a range that the recommendation refers to. + type: string + nextNotificationTime: + format: date-time + description: >- + When to notify this recommendation next. Null means that this will + never be notified anymore. + type: string + notificationExpirationTime: + format: date-time + description: Date and time when this notification expires. + type: string + notifiedTime: + format: date-time + description: >- + Last timestamp this instance was actually notified. Null means that + this recommendation hasn't been notified yet. + type: string + score: + format: double + description: A metric value measured by the rule. + type: number + RecommendationRule: + description: >- + Represents a recommendation rule that the recommendation engine can + perform + required: + - level + - channels + type: object + properties: + name: + description: Unique name of the rule + type: string + displayName: + description: UI friendly name of the rule + type: string + message: + description: Localized name of the rule (Good for UI) + type: string + recommendationId: + description: "Recommendation ID of an associated recommendation object tied to the rule, if exists.\r\n If such an object doesn't exist, it is set to null." + type: string + description: + description: Localized detailed description of the rule + type: string + actionName: + description: Name of action that is recommended by this rule in string + type: string + enabled: + format: int32 + description: On/off flag indicating the rule is currently enabled or disabled. + type: integer + level: + description: Level of impact indicating how critical this rule is. + enum: + - Critical + - Warning + - Information + - NonUrgentSuggestion + type: string + x-ms-enum: + name: NotificationLevel + modelAsString: false + channels: + description: List of available channels that this rule applies. + enum: + - Notification + - Api + - Email + - All + type: string + x-ms-enum: + name: Channels + modelAsString: false + tags: + description: An array of category tags that the rule contains. + type: array + items: + type: string + VnetInfo: + description: >- + VNETInfo contract. This contract is public and is a stripped down version + of VNETInfoInternal + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + vnetResourceId: + description: The vnet resource id + type: string + certThumbprint: + description: The client certificate thumbprint + type: string + certBlob: + description: "A certificate file (.cer) blob containing the public key of the private key used to authenticate a \r\n Point-To-Site VPN connection." + type: string + routes: + description: The routes that this virtual network connection uses. + type: array + items: + $ref: '#/definitions/VnetRoute' + resyncRequired: + description: Flag to determine if a resync is required + type: boolean + dnsServers: + description: >- + Dns servers to be used by this VNET. This should be a + comma-separated list of IP addresses. + type: string + x-ms-client-flatten: true + VnetRoute: + description: VnetRoute contract used to pass routing information for a vnet. + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: >- + The name of this route. This is only returned by the server and + does not need to be set by the client. + type: string + startAddress: + description: >- + The starting address for this route. This may also include a CIDR + notation, in which case the end address must not be specified. + type: string + endAddress: + description: >- + The ending address for this route. If the start address is + specified in CIDR notation, this must be omitted. + type: string + routeType: + description: "The type of route this is:\r\n DEFAULT - By default, every web app has routes to the local address ranges specified by RFC1918\r\n INHERITED - Routes inherited from the real Virtual Network routes\r\n STATIC - Static route set on the web app only\r\n \r\n These values will be used for syncing a Web App's routes with those from a Virtual Network. This operation will clear all DEFAULT and INHERITED routes and replace them\r\n with new INHERITED routes." + type: string + x-ms-client-flatten: true + VnetGateway: + description: >- + The VnetGateway contract. This is used to give the vnet gateway access to + the VPN package. + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + vnetName: + description: The VNET name. + type: string + vpnPackageUri: + description: The URI where the Vpn package can be downloaded + type: string + x-ms-client-flatten: true + NetworkFeatures: + description: "This is an object used to store a full view of network features (presently VNET integration and Hybrid Connections)\r\n for a web app." + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + virtualNetworkName: + description: The Vnet Name + type: string + virtualNetworkConnection: + $ref: '#/definitions/VnetInfo' + description: The Vnet Summary view + hybridConnections: + description: The Hybrid Connections Summary view + type: array + items: + $ref: '#/definitions/RelayServiceConnectionEntity' + x-ms-client-flatten: true + RelayServiceConnectionEntity: + description: Class that represents a Biztalk Hybrid Connection + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + entityName: + type: string + entityConnectionString: + type: string + resourceType: + type: string + resourceConnectionString: + type: string + hostname: + type: string + port: + format: int32 + type: integer + biztalkUri: + type: string + x-ms-client-flatten: true + CsmSlotEntity: + description: Class containing deployment slot parameters + type: object + properties: + targetSlot: + description: Set the destination deployment slot during swap operation + type: string + preserveVnet: + description: >- + Get or set the flag indicating it should preserve VNet to the slot + during swap + type: boolean + SlotDifferenceCollection: + description: Collection of Slot Differences + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/SlotDifference' + nextLink: + description: Link to next page of resources + type: string + SlotDifference: + description: >- + An object describing the difference in setting values between two web app + slots + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + type: + description: >- + Indicates the type of the difference: Information, Warning or + Error. + type: string + settingType: + description: 'The type of the settings: General, AppSetting or ConnectionString' + type: string + diffRule: + description: >- + Rule that describes how to process the difference in settings + during web app slot swap. + type: string + settingName: + description: Name of the setting + type: string + valueInCurrentSlot: + description: Value of the setting in the current web app slot + type: string + valueInTargetSlot: + description: Value of the setting in the target web app slot + type: string + description: + description: Description of the difference + type: string + x-ms-client-flatten: true + SlotConfigNamesResource: + description: Slot Config names azure resource + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + connectionStringNames: + description: List of connection string names + type: array + items: + type: string + appSettingNames: + description: List of application settings names + type: array + items: + type: string + x-ms-client-flatten: true + SlotConfigNames: + description: "Class containing names for connection strings and application settings to be marked as sticky to the slot \r\n and not moved during swap operation\r\n This is valid for all deployment slots under the site" + type: object + properties: + connectionStringNames: + description: List of connection string names + type: array + items: + type: string + appSettingNames: + description: List of application settings names + type: array + items: + type: string + SiteCloneability: + description: Represents whether or not a web app is cloneable + required: + - result + type: object + properties: + result: + description: Name of web app + enum: + - Cloneable + - PartiallyCloneable + - NotCloneable + type: string + x-ms-enum: + name: CloneAbilityResult + modelAsString: false + blockingFeatures: + description: List of features enabled on web app that prevent cloning + type: array + items: + $ref: '#/definitions/SiteCloneabilityCriterion' + unsupportedFeatures: + description: "List of features enabled on web app that are non-blocking but cannot be cloned. The web app can still be cloned\r\n but the features in this list will not be set up on cloned web app." + type: array + items: + $ref: '#/definitions/SiteCloneabilityCriterion' + blockingCharacteristics: + description: List of blocking application characteristics + type: array + items: + $ref: '#/definitions/SiteCloneabilityCriterion' + SiteCloneabilityCriterion: + description: Represents a site cloneability criterion + type: object + properties: + name: + description: Name of criterion + type: string + description: + description: Description of criterion + type: string + CsmSiteRecoveryEntity: + description: Class containting details about site recovery operation. + type: object + properties: + snapshotTime: + format: date-time + description: Point in time in which the site recover should be attempted. + type: string + recoverConfig: + description: >- + If true, then the website's configuration will be reverted to its + state at SnapshotTime + type: boolean + siteName: + description: >- + [Optional] Destination web app name into which web app should be + recovered. This is case when new web app should be created instead. + type: string + slotName: + description: >- + [Optional] Destination web app slot name into which web app should be + recovered + type: string + DeletedSiteCollection: + description: Collection of deleted sites + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/DeletedSite' + nextLink: + description: Link to next page of resources + type: string + DeletedSite: + description: Reports deleted site including the timestamp of operation + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - usageState + - availabilityState + properties: + deletedTimestamp: + format: date-time + description: Time when the site was deleted + type: string + name: + description: Name of web app + type: string + state: + description: State of the web app + type: string + readOnly: true + hostNames: + description: Hostnames associated with web app + type: array + items: + type: string + readOnly: true + repositorySiteName: + description: Name of repository site + type: string + readOnly: true + usageState: + description: State indicating whether web app has exceeded its quota usage + enum: + - Normal + - Exceeded + type: string + readOnly: true + x-ms-enum: + name: UsageState + modelAsString: false + enabled: + description: >- + True if the site is enabled; otherwise, false. Setting this value + to false disables the site (takes the site off line). + type: boolean + enabledHostNames: + description: "Hostnames for the web app that are enabled. Hostnames need to be assigned and enabled. If some hostnames are assigned but not enabled\r\n the app is not served on those hostnames" + type: array + items: + type: string + readOnly: true + availabilityState: + description: "Management information availability state for the web app. Possible values are Normal or Limited. \r\n Normal means that the site is running correctly and that management information for the site is available. \r\n Limited means that only partial management information for the site is available and that detailed site information is unavailable." + enum: + - Normal + - Limited + - DisasterRecoveryMode + type: string + readOnly: true + x-ms-enum: + name: SiteAvailabilityState + modelAsString: false + hostNameSslStates: + description: >- + Hostname SSL states are used to manage the SSL bindings for + site's hostnames. + type: array + items: + $ref: '#/definitions/HostNameSslState' + serverFarmId: + type: string + lastModifiedTimeUtc: + format: date-time + description: Last time web app was modified in UTC + type: string + readOnly: true + siteConfig: + $ref: '#/definitions/SiteConfig' + description: Configuration of web app + trafficManagerHostNames: + description: >- + Read-only list of Azure Traffic manager hostnames associated with + web app + type: array + items: + type: string + readOnly: true + premiumAppDeployed: + description: If set indicates whether web app is deployed as a premium app + type: boolean + readOnly: true + scmSiteAlsoStopped: + description: >- + If set indicates whether to stop SCM (KUDU) site when the web app + is stopped. Default is false. + type: boolean + targetSwapSlot: + description: >- + Read-only property that specifies which slot this app will swap + into + type: string + readOnly: true + hostingEnvironmentProfile: + $ref: '#/definitions/HostingEnvironmentProfile' + description: >- + Specification for the hosting environment (App Service + Environment) to use for the web app + microService: + description: '' + type: string + gatewaySiteName: + description: Name of gateway app associated with web app + type: string + clientAffinityEnabled: + description: >- + Specifies if the client affinity is enabled when load balancing + http request for multiple instances of the web app + type: boolean + clientCertEnabled: + description: Specifies if the client certificate is enabled for the web app + type: boolean + hostNamesDisabled: + description: "Specifies if the public hostnames are disabled the web app.\r\n If set to true the app is only accessible via API Management process" + type: boolean + outboundIpAddresses: + description: >- + List of comma separated IP addresses that this web app uses for + outbound connections. Those can be used when configuring firewall + rules for databases accessed by this web app. + type: string + readOnly: true + containerSize: + format: int32 + description: Size of a function container + type: integer + maxNumberOfWorkers: + format: int32 + description: "Maximum number of workers\r\n This only applies to function container" + type: integer + cloningInfo: + $ref: '#/definitions/CloningInfo' + description: "This is only valid for web app creation. If specified, web app is cloned from \r\n a source web app" + resourceGroup: + description: Resource group web app belongs to + type: string + readOnly: true + isDefaultContainer: + description: Site is a default container + type: boolean + readOnly: true + defaultHostName: + description: Default hostname of the web app + type: string + readOnly: true + x-ms-client-flatten: true + DeploymentCollection: + description: Collection of app deployments + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/Deployment' + nextLink: + description: Link to next page of resources + type: string + Deployment: + description: Represents user crendentials used for publishing activity + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + id: + description: Id + type: string + status: + format: int32 + description: Status + type: integer + message: + description: Message + type: string + author: + description: Author + type: string + deployer: + description: Deployer + type: string + author_email: + description: AuthorEmail + type: string + start_time: + format: date-time + description: StartTime + type: string + end_time: + format: date-time + description: EndTime + type: string + active: + description: Active + type: boolean + details: + description: Detail + type: string + x-ms-client-flatten: true + SiteInstanceCollection: + description: Collection of site instances + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/SiteInstance' + nextLink: + description: Link to next page of resources + type: string + SiteInstance: + description: Instance of a web app + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Name of instance + type: string + x-ms-client-flatten: true + HostNameBindingCollection: + description: Collection of host name bindings + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/HostNameBinding' + nextLink: + description: Link to next page of resources + type: string + HostNameBinding: + description: A host name binding object + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Hostname + type: string + siteName: + description: Web app name + type: string + domainId: + description: Fully qualified ARM domain resource URI + type: string + azureResourceName: + description: Azure resource name + type: string + azureResourceType: + description: Azure resource type + enum: + - Website + - TrafficManager + type: string + x-ms-enum: + name: AzureResourceType + modelAsString: false + customHostNameDnsRecordType: + description: Custom DNS record type + enum: + - CName + - A + type: string + x-ms-enum: + name: CustomHostNameDnsRecordType + modelAsString: false + hostNameType: + description: Host name type + enum: + - Verified + - Managed + type: string + x-ms-enum: + name: HostNameType + modelAsString: false + x-ms-client-flatten: true + SiteSourceControl: + description: Describes the source control configuration for web app + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + repoUrl: + description: Repository or source control url + type: string + branch: + description: Name of branch to use for deployment + type: string + isManualIntegration: + description: Whether to manual or continuous integration + type: boolean + deploymentRollbackEnabled: + description: Whether to manual or continuous integration + type: boolean + isMercurial: + description: Mercurial or Git repository type + type: boolean + x-ms-client-flatten: true + StringDictionary: + description: String dictionary resource + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + description: Settings + type: object + additionalProperties: + type: string + x-ms-client-flatten: true + ConnectionStringDictionary: + description: String dictionary resource + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + description: Connection strings + type: object + additionalProperties: + $ref: '#/definitions/ConnStringValueTypePair' + x-ms-client-flatten: true + ConnStringValueTypePair: + description: Database connection string value to type pair + required: + - type + type: object + properties: + value: + description: Value of pair + type: string + type: + description: Type of database + enum: + - MySql + - SQLServer + - SQLAzure + - Custom + type: string + x-ms-enum: + name: DatabaseServerType + modelAsString: false + SiteLogsConfig: + description: Configuration of Azure web site + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + applicationLogs: + $ref: '#/definitions/ApplicationLogsConfig' + description: Application logs configuration + httpLogs: + $ref: '#/definitions/HttpLogsConfig' + description: Http logs configuration + failedRequestsTracing: + $ref: '#/definitions/EnabledConfig' + description: Failed requests tracing configuration + detailedErrorMessages: + $ref: '#/definitions/EnabledConfig' + description: Detailed error messages configuration + x-ms-client-flatten: true + ApplicationLogsConfig: + description: Application logs configuration + type: object + properties: + fileSystem: + $ref: '#/definitions/FileSystemApplicationLogsConfig' + description: Application logs to file system configuration + azureTableStorage: + $ref: '#/definitions/AzureTableStorageApplicationLogsConfig' + description: Application logs to azure table storage configuration + azureBlobStorage: + $ref: '#/definitions/AzureBlobStorageApplicationLogsConfig' + description: Application logs to blob storage configuration + HttpLogsConfig: + description: Http logs configuration + type: object + properties: + fileSystem: + $ref: '#/definitions/FileSystemHttpLogsConfig' + description: Http logs to file system configuration + azureBlobStorage: + $ref: '#/definitions/AzureBlobStorageHttpLogsConfig' + description: Http logs to azure blob storage configuration + EnabledConfig: + description: Enabled configuration + type: object + properties: + enabled: + description: Enabled + type: boolean + FileSystemApplicationLogsConfig: + description: Application logs to file system configuration + type: object + properties: + level: + description: Log level + enum: + - 'Off' + - Verbose + - Information + - Warning + - Error + type: string + x-ms-enum: + name: LogLevel + modelAsString: false + AzureTableStorageApplicationLogsConfig: + description: Application logs to azure table storage configuration + type: object + properties: + level: + description: Log level + enum: + - 'Off' + - Verbose + - Information + - Warning + - Error + type: string + x-ms-enum: + name: LogLevel + modelAsString: false + sasUrl: + description: SAS url to an azure table with add/query/delete permissions + type: string + AzureBlobStorageApplicationLogsConfig: + description: Application logs azure blob storage configuration + type: object + properties: + level: + description: Log level + enum: + - 'Off' + - Verbose + - Information + - Warning + - Error + type: string + x-ms-enum: + name: LogLevel + modelAsString: false + sasUrl: + description: >- + SAS url to a azure blob container with read/write/list/delete + permissions + type: string + retentionInDays: + format: int32 + description: "Retention in days.\r\n Remove blobs older than X days.\r\n 0 or lower means no retention." + type: integer + FileSystemHttpLogsConfig: + description: Http logs to file system configuration + type: object + properties: + retentionInMb: + format: int32 + description: "Maximum size in megabytes that http log files can use.\r\n When reached old log files will be removed to make space for new ones.\r\n Value can range between 25 and 100." + type: integer + retentionInDays: + format: int32 + description: "Retention in days.\r\n Remove files older than X days.\r\n 0 or lower means no retention." + type: integer + enabled: + description: Enabled + type: boolean + AzureBlobStorageHttpLogsConfig: + description: Http logs to azure blob storage configuration + type: object + properties: + sasUrl: + description: >- + SAS url to a azure blob container with read/write/list/delete + permissions + type: string + retentionInDays: + format: int32 + description: "Retention in days.\r\n Remove blobs older than X days.\r\n 0 or lower means no retention." + type: integer + enabled: + description: Enabled + type: boolean + PremierAddOnRequest: + type: object + properties: + location: + description: 'Geo region resource belongs to e.g. SouthCentralUS, SouthEastAsia' + type: string + tags: + description: Tags associated with resource + type: object + additionalProperties: + type: string + plan: + $ref: '#/definitions/ArmPlan' + description: Azure resource manager plan + properties: + $ref: '#/definitions/Object' + description: Resource specific properties + sku: + $ref: '#/definitions/SkuDescription' + description: Sku description of the resource + BackupRequest: + description: Description of a backup which will be performed + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - type + properties: + name: + description: Name of the backup + type: string + enabled: + description: >- + True if the backup schedule is enabled (must be included in that + case), false if the backup schedule should be disabled + type: boolean + storageAccountUrl: + description: SAS URL to the container + type: string + backupSchedule: + $ref: '#/definitions/BackupSchedule' + description: Schedule for the backup if it is executed periodically + databases: + description: Databases included in the backup + type: array + items: + $ref: '#/definitions/DatabaseBackupSetting' + type: + description: Type of the backup + enum: + - Default + - Clone + - Relocation + type: string + x-ms-enum: + name: BackupRestoreOperationType + modelAsString: false + x-ms-client-flatten: true + BackupSchedule: + description: >- + Description of a backup schedule. Describes how often should be the backup + performed and what should be the retention policy. + required: + - frequencyUnit + type: object + properties: + frequencyInterval: + format: int32 + description: >- + How often should be the backup executed (e.g. for weekly backup, this + should be set to 7 and FrequencyUnit should be set to Day) + type: integer + frequencyUnit: + description: >- + How often should be the backup executed (e.g. for weekly backup, this + should be set to Day and FrequencyInterval should be set to 7) + enum: + - Day + - Hour + type: string + x-ms-enum: + name: FrequencyUnit + modelAsString: false + keepAtLeastOneBackup: + description: >- + True if the retention policy should always keep at least one backup in + the storage account, regardless how old it is; false otherwise. + type: boolean + retentionPeriodInDays: + format: int32 + description: After how many days backups should be deleted + type: integer + startTime: + format: date-time + description: When the schedule should start working + type: string + lastExecutionTime: + format: date-time + description: The last time when this schedule was triggered + type: string + DatabaseBackupSetting: + description: "Note: properties are serialized in JSON format and stored in DB. \r\n if new properties are added they might not be in the previous data rows \r\n so please handle nulls" + type: object + properties: + databaseType: + description: SqlAzure / MySql + type: string + name: + type: string + connectionStringName: + description: "Contains a connection string name that is linked to the SiteConfig.ConnectionStrings.\r\n This is used during restore with overwrite connection strings options." + type: string + connectionString: + description: >- + Contains a connection string to a database which is being backed + up/restored. If the restore should happen to a new database, the + database name inside is the new one. + type: string + BackupItem: + description: Backup description + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - status + properties: + id: + format: int32 + description: Id of the backup. + type: integer + storageAccountUrl: + description: >- + SAS URL for the storage account container which contains this + backup + type: string + blobName: + description: Name of the blob which contains data for this backup + type: string + name: + description: Name of this backup + type: string + status: + description: Backup status + enum: + - InProgress + - Failed + - Succeeded + - TimedOut + - Created + - Skipped + - PartiallySucceeded + - DeleteInProgress + - DeleteFailed + - Deleted + type: string + x-ms-enum: + name: BackupItemStatus + modelAsString: false + sizeInBytes: + format: int64 + description: Size of the backup in bytes + type: integer + created: + format: date-time + description: Timestamp of the backup creation + type: string + log: + description: Details regarding this backup. Might contain an error message. + type: string + databases: + description: List of databases included in the backup + type: array + items: + $ref: '#/definitions/DatabaseBackupSetting' + scheduled: + description: >- + True if this backup has been created due to a schedule being + triggered. + type: boolean + lastRestoreTimeStamp: + format: date-time + description: Timestamp of a last restore operation which used this backup. + type: string + finishedTimeStamp: + format: date-time + description: Timestamp when this backup finished. + type: string + correlationId: + description: >- + Unique correlation identifier. Please use this along with the + timestamp while communicating with Azure support. + type: string + websiteSizeInBytes: + format: int64 + description: Size of the original web app which has been backed up + type: integer + x-ms-client-flatten: true + RestoreRequest: + description: Description of a restore request + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + required: + - operationType + properties: + storageAccountUrl: + description: SAS URL to the container + type: string + blobName: + description: Name of a blob which contains the backup + type: string + overwrite: + description: >- + True if the restore operation can overwrite target site. "True" + needed if trying to restore over an existing site. + type: boolean + siteName: + description: Name of a site (Web App) + type: string + databases: + description: >- + Collection of databses which should be restored. This list has to + match the list of databases included in the backup. + type: array + items: + $ref: '#/definitions/DatabaseBackupSetting' + ignoreConflictingHostNames: + description: "Changes a logic when restoring a site with custom domains. If \"true\", custom domains are removed automatically. If \"false\", custom domains are added to \r\n the site object when it is being restored, but that might fail due to conflicts during the operation." + type: boolean + operationType: + description: Operation type + enum: + - Default + - Clone + - Relocation + type: string + x-ms-enum: + name: BackupRestoreOperationType + modelAsString: false + adjustConnectionStrings: + description: >- + Gets or sets a flag showing if SiteConfig.ConnectionStrings should + be set in new site + type: boolean + hostingEnvironment: + description: >- + App Service Environment name, if needed (only when restoring a + site to an App Service Environment) + type: string + x-ms-client-flatten: true + BackupItemCollection: + description: Collection of Backup Items + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/BackupItem' + nextLink: + description: Link to next page of resources + type: string + RestoreResponse: + description: Response for a restore site request + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + operationId: + description: >- + When server starts the restore process, it will return an + OperationId identifying that particular restore operation + type: string + x-ms-client-flatten: true + CsmPublishingProfileOptions: + description: Publishing options for requested profile + type: object + properties: + format: + description: "Name of the format. Valid values are: \r\n FileZilla3\r\n WebDeploy -- default\r\n Ftp" + type: string + TopLevelDomainCollection: + description: Collection of Top Level Domains + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/TopLevelDomain' + nextLink: + description: Link to next page of resources + type: string + TopLevelDomain: + description: A top level domain object + type: object + allOf: + - $ref: '#/definitions/Resource' + properties: + properties: + properties: + name: + description: Name of the top level domain + type: string + privacy: + description: If true then the top level domain supports domain privacy + type: boolean + x-ms-client-flatten: true + TopLevelDomainAgreementOption: + description: Options for retrieving the list of top level domain legal agreements + type: object + properties: + includePrivacy: + description: >- + If true then the list of agreements will inclue agreements for domain + privacy as well. + type: boolean + TldLegalAgreementCollection: + description: Collection of Tld Legal Agreements + type: object + properties: + value: + description: Collection of resources + type: array + items: + $ref: '#/definitions/TldLegalAgreement' + nextLink: + description: Link to next page of resources + type: string + TldLegalAgreement: + description: Represents a legal agreement for top level domain + type: object + properties: + agreementKey: + description: Unique identifier for the agreement + type: string + title: + description: Agreement title + type: string + content: + description: Agreement details + type: string + url: + description: Url where a copy of the agreement details is hosted + type: string + Resource: + required: + - location + properties: + id: + description: Resource Id + type: string + name: + description: Resource Name + type: string + kind: + description: Kind of resource + type: string + location: + description: Resource Location + type: string + type: + description: Resource type + type: string + tags: + description: Resource tags + type: object + additionalProperties: + type: string + x-ms-azure-resource: true +parameters: + subscriptionIdParameter: + name: subscriptionId + in: path + description: Subscription Id + required: true + type: string + apiVersionParameter: + name: api-version + in: query + description: API Version + required: true + type: string +securityDefinitions: + azure_auth: + type: oauth2 + description: Azure Active Directory OAuth2 Flow + flow: implicit + authorizationUrl: 'https://login.microsoftonline.com/common/oauth2/authorize' + scopes: + user_impersonation: impersonate your user account +security: + - azure_auth: + - user_impersonation diff --git a/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj b/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj index 76cdda60224f..9984e9023b63 100644 --- a/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj +++ b/AutoRest/Modelers/Swagger.Tests/AutoRest.Modeler.Swagger.Tests.csproj @@ -51,7 +51,7 @@ PreserveNewest - + PreserveNewest @@ -84,6 +84,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-simple-spec.yaml b/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-simple-spec.yaml new file mode 100644 index 000000000000..545e16361b06 --- /dev/null +++ b/AutoRest/Modelers/Swagger.Tests/Swagger/swagger-simple-spec.yaml @@ -0,0 +1,128 @@ +swagger: '2.0' +info: + title: Microsoft Azure Redis Cache Management API + description: Some cool documentation. + version: 2014-04-01-preview +host: management.azure.com +schemes: + - https +basePath: / +produces: + - application/json +consumes: + - application/json +paths: + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}': + get: + operationId: list + summary: Product Types + description: >- + The Products endpoint returns information about the Uber products + offered at a given location. The response includes the display name and + other details about each product, and lists the products in the proper + display order. + parameters: + - $ref: '#/parameters/SubscriptionIdParamterer' + - name: resourceGroupName + in: path + description: Resource Group ID. + required: true + type: string + - $ref: ApiVersionParameter + tags: + - Redis + responses: + '200': + description: A list of caches + schema: + $ref: Product + default: + description: Unexpected error + schema: + $ref: Error + post: + operationId: reset + summary: Resets products + description: Resets products. + parameters: + - name: subscriptionId + in: path + description: Subscription ID. + required: true + type: string + - name: resourceGroupName + in: path + description: Resource Group ID. + required: true + type: string + - name: apiVersion + in: path + description: API ID. + required: true + type: string + tags: + - Redis + responses: + '204': + description: A list of caches + examples: + application/json: + id: 9 + category: + name: domestic + name: monster + tags: + - name: for sale + status: alive + default: + description: Unexpected error + schema: + $ref: Error +definitions: + Product: + description: The product documentation. + properties: + product_id: + type: string + description: >- + Unique identifier representing a specific product for a given latitude + & longitude. For example, uberX in San Francisco will have a different + product_id than uberX in Los Angeles. + description: + type: string + description: Description of product. + display_name: + type: string + description: Display name of product. + capacity: + type: string + description: 'Capacity of product. For example, 4 people.' + default: '100' + image: + type: string + description: Image URL representing the product. + example: + name: Puma + id: 1 + Error: + properties: + code: + type: integer + format: int32 + message: + type: string + fields: + type: string +parameters: + SubscriptionIdParamterer: + name: subscriptionId + in: path + description: Subscription ID. + required: true + type: string + ApiVersionParameter: + name: apiVersion + in: path + description: API ID. + required: true + type: string diff --git a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs index 6083741a77c6..062e232c519b 100644 --- a/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs +++ b/AutoRest/Modelers/Swagger.Tests/SwaggerModelerTests.cs @@ -621,5 +621,18 @@ public void TestParameterizedHostFromSwagger() Assert.Equal(2, jArrayParameters.Count); Assert.Equal("{accountName}.{host}", hostTemplate); } + + [Fact] + public void TestYamlParsing() + { + Generator.Modeler modeler = new SwaggerModeler(new Settings + { + Namespace = "Test", + Input = Path.Combine("Swagger", "swagger-simple-spec.yaml") + }); + var clientModel = modeler.Build(); + + Assert.NotNull(clientModel); + } } } diff --git a/AutoRest/Modelers/Swagger/AutoRest.Modeler.Swagger.csproj b/AutoRest/Modelers/Swagger/AutoRest.Modeler.Swagger.csproj index bc7b99e85aed..7d18d0068a1c 100644 --- a/AutoRest/Modelers/Swagger/AutoRest.Modeler.Swagger.csproj +++ b/AutoRest/Modelers/Swagger/AutoRest.Modeler.Swagger.csproj @@ -67,6 +67,7 @@ + @@ -88,5 +89,11 @@ CustomDictionary.xml + + + ..\..\..\packages\YamlDotNet.3.8.0\lib\net35\YamlDotNet.dll + True + + \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger/Extensions.cs b/AutoRest/Modelers/Swagger/Extensions.cs index a07ea4a8cb46..26db63d6c21f 100644 --- a/AutoRest/Modelers/Swagger/Extensions.cs +++ b/AutoRest/Modelers/Swagger/Extensions.cs @@ -3,8 +3,11 @@ using System; using System.Globalization; +using System.IO; using System.Net; using Microsoft.Rest.Generator.ClientModel; +using Newtonsoft.Json; +using YamlDotNet.Serialization; namespace Microsoft.Rest.Modeler.Swagger { @@ -77,5 +80,24 @@ public static string StripParameterPath(this string reference) return reference; } + + public static string EnsureYamlIsJson(this string text) + { + // is this something other than JSON? + if (!string.IsNullOrWhiteSpace(text) && text[0] != '{') + { + using (var y = new StringReader(text)) + { + using (var s = new StringWriter(CultureInfo.CurrentCulture)) + { + var d = new Deserializer(); + d.NodeDeserializers.Insert( 0,new YamlBoolDeserializer() ); + new JsonSerializer().Serialize(s, d.Deserialize(y)); + return s.ToString(); + } + } + } + return text; + } } } \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger/SwaggerParser.cs b/AutoRest/Modelers/Swagger/SwaggerParser.cs index eb9691f725e4..1ad21fb7c976 100644 --- a/AutoRest/Modelers/Swagger/SwaggerParser.cs +++ b/AutoRest/Modelers/Swagger/SwaggerParser.cs @@ -29,6 +29,7 @@ public static ServiceDefinition Parse(string swaggerDocument) { try { + swaggerDocument = swaggerDocument.EnsureYamlIsJson(); var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None, diff --git a/AutoRest/Modelers/Swagger/YamlBoolDeserializer.cs b/AutoRest/Modelers/Swagger/YamlBoolDeserializer.cs new file mode 100644 index 000000000000..6e4e11d76ec5 --- /dev/null +++ b/AutoRest/Modelers/Swagger/YamlBoolDeserializer.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization; + +namespace Microsoft.Rest.Modeler.Swagger +{ + public class YamlBoolDeserializer : INodeDeserializer + { + public bool Deserialize(EventReader reader, Type expectedType, Func nestedObjectDeserializer, out object value) + { + if (reader == null) + { + value = null; + return false; + } + + // only try this if we're targeting a boolean or an untyped object + if (expectedType == typeof(object) || expectedType == typeof(bool) ) + { + // peek at the current token + Scalar scalar = reader.Peek(); + + // if it's unquoted + if (scalar != null && scalar.Style == ScalarStyle.Plain) + { + // and the value is actually true or false + switch (scalar.Value.ToUpperInvariant()) + { + case "TRUE": + value = true; + reader.Allow(); + return true; + case "FALSE": + value = false; + reader.Allow(); + return true; + + } + } + } + + // otherwise, fall thru + value = null; + return false; + } + } +} \ No newline at end of file diff --git a/AutoRest/Modelers/Swagger/packages.config b/AutoRest/Modelers/Swagger/packages.config index 505e58836bae..798412113f05 100644 --- a/AutoRest/Modelers/Swagger/packages.config +++ b/AutoRest/Modelers/Swagger/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/Tools/CustomDictionary.xml b/Tools/CustomDictionary.xml index e06bd1edb439..0e5a4f27eb2f 100644 --- a/Tools/CustomDictionary.xml +++ b/Tools/CustomDictionary.xml @@ -37,6 +37,8 @@ Impl odata Uuid + Yaml + Deserializer \ No newline at end of file diff --git a/Tools/references.net45.props b/Tools/references.net45.props index 0f12281cd4cf..9642e08e9331 100644 --- a/Tools/references.net45.props +++ b/Tools/references.net45.props @@ -18,5 +18,8 @@ $(CommonNugetPackageFolder)\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + $(CommonNugetPackageFolder)\YamlDotNet.3.8.0\lib\dotnet\YamlDotNet.dll + diff --git a/build.proj b/build.proj index 5a2cb4027326..4d3c319340b7 100644 --- a/build.proj +++ b/build.proj @@ -199,7 +199,7 @@ + Exclude="binaries\net45\Newtonsoft.*.dll;binaries\net45\YamlDotNet.*.dll" /> Date: Fri, 27 May 2016 12:13:42 -0700 Subject: [PATCH 18/23] Added XXXWithHttpMessages() method --- .../CSharp/AutoRest.Generator.CSharp.csproj | 1 + .../CSharp/SyncWrapperGenerationMode.cs | 16 ++++++++++ .../TemplateModels/MethodTemplateModel.cs | 29 +++++++++++++++---- .../Templates/ExtensionMethodTemplate.cshtml | 29 +++++++++++++++++++ 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs diff --git a/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj b/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj index 1a54330cc909..4885670c6bdc 100644 --- a/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj +++ b/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj @@ -36,6 +36,7 @@ True Resources.resx + diff --git a/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs b/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs new file mode 100644 index 000000000000..a5112f2b2e86 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + + +namespace Microsoft.Rest.Generator.CSharp +{ + /// + /// Defines supported modes for sync wrapper generation + /// + public enum SyncWrapperGenerationMode + { + All = 0, + Essential = 1, + None = 2 + } +} diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs index 22d1ca54614d..c27bb73925fb 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs @@ -92,22 +92,39 @@ public virtual string GetAsyncMethodParameterDeclaration() } /// - /// Generate the method parameter declaration for async methods and extensions + /// Generate the method parameter declaration for sync methods and extensions /// /// If true add the customHeader to the parameters /// Generated string of parameters - public virtual string GetAsyncMethodParameterDeclaration(bool addCustomHeaderParameters) + public virtual string GetSyncMethodParameterDeclaration(bool addCustomHeaderParameters) { var declarations = this.SyncMethodParameterDeclaration; - if (!string.IsNullOrEmpty(declarations)) + if (!string.IsNullOrEmpty(declarations) && addCustomHeaderParameters) { declarations += ", "; } if (addCustomHeaderParameters) { - declarations += "Dictionary> customHeaders = null, "; + declarations += "Dictionary> customHeaders = null"; } + + return declarations; + } + + /// + /// Generate the method parameter declaration for async methods and extensions + /// + /// If true add the customHeader to the parameters + /// Generated string of parameters + public virtual string GetAsyncMethodParameterDeclaration(bool addCustomHeaderParameters) + { + var declarations = this.GetSyncMethodParameterDeclaration(addCustomHeaderParameters); + + if (!string.IsNullOrEmpty(declarations)) + { + declarations += ", "; + } declarations += "CancellationToken cancellationToken = default(CancellationToken)"; return declarations; @@ -129,12 +146,12 @@ public string SyncMethodInvocationArgs /// /// Get the invocation args for an invocation with an async method /// - public string GetAsyncMethodInvocationArgs (string customHeaderReference) + public string GetAsyncMethodInvocationArgs (string customHeaderReference, string cancellationTokenReference = "cancellationToken") { List invocationParams = new List(); LocalParameters.ForEach(p => invocationParams.Add(p.Name)); invocationParams.Add(customHeaderReference); - invocationParams.Add("cancellationToken"); + invocationParams.Add(cancellationTokenReference); return string.Join(", ", invocationParams); } diff --git a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml index aaba0ea91e17..c831d5619b74 100644 --- a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml +++ b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml @@ -40,6 +40,7 @@ foreach (var parameter in Model.LocalParameters) @:Task.Factory.StartNew(s => ((I@(Model.MethodGroupName))s).@(Model.Name)Async(@(Model.SyncMethodInvocationArgs)), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); } @:} + @EmptyLine @if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) { @@ -93,5 +94,33 @@ foreach (var parameter in Model.LocalParameters) @:await operations.@(Model.Name)WithHttpMessagesAsync(@(Model.GetAsyncMethodInvocationArgs("null"))).ConfigureAwait(false); } @:} + +@EmptyLine +@if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) +{ +@:/// +@:@WrapComment("/// ", String.IsNullOrEmpty(Model.Summary) ? Model.Description.EscapeXmlComment() : Model.Summary.EscapeXmlComment()) +@:/// +} +@if (!String.IsNullOrEmpty(Model.Description) && !String.IsNullOrEmpty(Model.Summary)) +{ +@:@WrapComment("/// ", Model.Description.EscapeXmlComment()) +} +@:/// +@:/// The operations group for this extension method. +@:/// +foreach (var parameter in Model.LocalParameters) +{ +@:/// +@:@WrapComment("/// ", parameter.Documentation.EscapeXmlComment()) +@:/// +} +@:/// +@:/// Headers that will be added to request. +@:/// +@:public static @Model.OperationResponseReturnTypeString @(Model.Name)WithHttpMessages(@Model.GetExtensionParameters(Model.GetSyncMethodParameterDeclaration(true))) +@:{ +@: return operations.@(Model.Name)WithHttpMessagesAsync(@(Model.GetAsyncMethodInvocationArgs("customHeaders", "CancellationToken.None"))).ConfigureAwait(false).GetAwaiter().GetResult(); +@:} @: } From b338faa3b33a6933836bb9a61dcfec5f90e641cf Mon Sep 17 00:00:00 2001 From: stankovski Date: Fri, 27 May 2016 12:34:03 -0700 Subject: [PATCH 19/23] Propagated SyncWrapper property --- .../Azure.CSharp/AzureCSharpCodeGenerator.cs | 4 +- .../AzureExtensionsTemplateModel.cs | 6 +-- .../AzureMethodGroupTemplateModel.cs | 2 +- .../AzureMethodTemplateModel.cs | 6 +-- .../AzureServiceClientTemplateModel.cs | 2 +- .../CSharp/CSharp/CSharpCodeGenerator.cs | 10 +++- .../CSharp/SyncWrapperGenerationMode.cs | 6 +-- .../TemplateModels/ExtensionsTemplateModel.cs | 4 +- .../MethodGroupTemplateModel.cs | 2 +- .../TemplateModels/MethodTemplateModel.cs | 5 +- .../ServiceClientTemplateModel.cs | 2 +- .../Templates/ExtensionMethodTemplate.cshtml | 48 +++++++++++-------- 12 files changed, 56 insertions(+), 41 deletions(-) diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs b/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs index 5c7f0b5bb380..85f9fe326a90 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs @@ -99,7 +99,7 @@ public override async Task Generate(ServiceClient serviceClient) { var extensionsTemplate = new ExtensionsTemplate { - Model = new AzureExtensionsTemplateModel(serviceClient, null), + Model = new AzureExtensionsTemplateModel(serviceClient, null, SyncWrappers), }; await Write(extensionsTemplate, serviceClient.Name + "Extensions.cs"); } @@ -124,7 +124,7 @@ public override async Task Generate(ServiceClient serviceClient) // Service client extensions var operationExtensionsTemplate = new ExtensionsTemplate { - Model = new AzureExtensionsTemplateModel(serviceClient, group), + Model = new AzureExtensionsTemplateModel(serviceClient, group, SyncWrappers), }; await Write(operationExtensionsTemplate, operationExtensionsTemplate.Model.ExtensionName + "Extensions.cs"); diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs index 61dcf09a9f67..8dcb1228f5da 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs @@ -12,12 +12,12 @@ namespace Microsoft.Rest.Generator.CSharp.Azure { public class AzureExtensionsTemplateModel : ExtensionsTemplateModel { - public AzureExtensionsTemplateModel(ServiceClient serviceClient, string operationName) - : base(serviceClient, operationName) + public AzureExtensionsTemplateModel(ServiceClient serviceClient, string operationName, SyncWrapperGenerationMode syncWrappers) + : base(serviceClient, operationName, syncWrappers) { MethodTemplateModels.Clear(); Methods.Where(m => m.Group == operationName) - .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient))); + .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, syncWrappers))); if (ExtensionName != Name) { ExtensionName = ExtensionName + "Operations"; diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs index 62f94ccf92d4..ecadbc1708f8 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs @@ -20,7 +20,7 @@ public AzureMethodGroupTemplateModel(ServiceClient serviceClient, string methodG // AzureMethodTemplateModel MethodTemplateModels.Clear(); Methods.Where(m => m.Group == methodGroupName) - .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient))); + .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); } /// diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs index 1a2b58cc1ada..e393a7d502ed 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs @@ -15,8 +15,8 @@ namespace Microsoft.Rest.Generator.CSharp.Azure { public class AzureMethodTemplateModel : MethodTemplateModel { - public AzureMethodTemplateModel(Method source, ServiceClient serviceClient) - : base(source, serviceClient) + public AzureMethodTemplateModel(Method source, ServiceClient serviceClient, SyncWrapperGenerationMode syncWrappers) + : base(source, serviceClient, syncWrappers) { if (source == null) { @@ -54,7 +54,7 @@ public AzureMethodTemplateModel GetMethod Resources.InvalidLongRunningOperationForCreateOrUpdate, Name, Group)); } - return new AzureMethodTemplateModel(getMethod, ServiceClient); + return new AzureMethodTemplateModel(getMethod, ServiceClient, SyncWrappers); } } diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs index 6a01deec30e7..a790ba0367f6 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs @@ -18,7 +18,7 @@ public AzureServiceClientTemplateModel(ServiceClient serviceClient, bool interna // TODO: Initialized in the base constructor. Why Clear it? MethodTemplateModels.Clear(); Methods.Where(m => m.Group == null) - .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient))); + .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); } /// diff --git a/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs b/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs index b43de08e365b..8655910279e8 100644 --- a/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs +++ b/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs @@ -29,6 +29,12 @@ public CSharpCodeGenerator(Settings settings) : base(settings) [SettingsAlias("internal")] public bool InternalConstructors { get; set; } + /// + /// Specifies mode for generating sync wrappers. + /// + [SettingsInfo("Specifies mode for generating sync wrappers.")] + public SyncWrapperGenerationMode SyncWrappers { get; set; } + public override string Name { get { return "CSharp"; } @@ -106,7 +112,7 @@ public override async Task Generate(ServiceClient serviceClient) { var extensionsTemplate = new ExtensionsTemplate { - Model = new ExtensionsTemplateModel(serviceClient, null), + Model = new ExtensionsTemplateModel(serviceClient, null, SyncWrappers), }; await Write(extensionsTemplate, serviceClient.Name + "Extensions.cs"); } @@ -131,7 +137,7 @@ public override async Task Generate(ServiceClient serviceClient) // Service client extensions var operationExtensionsTemplate = new ExtensionsTemplate { - Model = new ExtensionsTemplateModel(serviceClient, group), + Model = new ExtensionsTemplateModel(serviceClient, group, SyncWrappers), }; await Write(operationExtensionsTemplate, group + "Extensions.cs"); diff --git a/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs b/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs index a5112f2b2e86..72e4088bb863 100644 --- a/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs +++ b/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs @@ -9,8 +9,8 @@ namespace Microsoft.Rest.Generator.CSharp /// public enum SyncWrapperGenerationMode { - All = 0, - Essential = 1, - None = 2 + Essential, + All, + None } } diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs index a6b969b363b7..287311fe2708 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs @@ -10,13 +10,13 @@ namespace Microsoft.Rest.Generator.CSharp { public class ExtensionsTemplateModel : ServiceClient { - public ExtensionsTemplateModel(ServiceClient serviceClient, string operationName) + public ExtensionsTemplateModel(ServiceClient serviceClient, string operationName, SyncWrapperGenerationMode syncWrappers) { this.LoadFrom(serviceClient); MethodTemplateModels = new List(); ExtensionName = operationName ?? this.Name; this.Methods.Where(m => m.Group == operationName) - .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient))); + .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient, syncWrappers))); } diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs index 3a12b4da9a41..9c4c3ebcc37d 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs @@ -19,7 +19,7 @@ public MethodGroupTemplateModel(ServiceClient serviceClient, string methodGroupN MethodGroupName = methodGroupName; MethodGroupType = methodGroupName; Methods.Where(m => m.Group == MethodGroupName) - .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient))); + .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); } public List MethodTemplateModels { get; private set; } diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs index c27bb73925fb..a5bfcd56b30a 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs @@ -14,9 +14,10 @@ namespace Microsoft.Rest.Generator.CSharp { public class MethodTemplateModel : Method { - public MethodTemplateModel(Method source, ServiceClient serviceClient) + public MethodTemplateModel(Method source, ServiceClient serviceClient, SyncWrapperGenerationMode syncWrappers) { this.LoadFrom(source); + SyncWrappers = syncWrappers; ParameterTemplateModels = new List(); LogicalParameterTemplateModels = new List(); source.Parameters.ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p))); @@ -30,6 +31,8 @@ public MethodTemplateModel(Method source, ServiceClient serviceClient) public bool IsCustomBaseUri { get; private set; } + public SyncWrapperGenerationMode SyncWrappers { get; private set; } + public ServiceClient ServiceClient { get; set; } public List ParameterTemplateModels { get; private set; } diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs index f8c2d1174df2..b38f1db38b18 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs @@ -16,7 +16,7 @@ public ServiceClientTemplateModel(ServiceClient serviceClient, bool internalCons this.LoadFrom(serviceClient); MethodTemplateModels = new List(); Methods.Where(m => m.Group == null) - .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient))); + .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); ConstructorVisibility = internalConstructors ? "internal" : "public"; this.IsCustomBaseUri = serviceClient.Extensions.ContainsKey(Microsoft.Rest.Generator.Extensions.ParameterizedHostExtension); } diff --git a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml index c831d5619b74..d2531c48e398 100644 --- a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml +++ b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml @@ -6,25 +6,27 @@ @using Microsoft.Rest.Generator.Utilities @inherits Microsoft.Rest.Generator.Template @{ -@if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) +if (Model.SyncWrappers == SyncWrapperGenerationMode.All || Model.SyncWrappers == SyncWrapperGenerationMode.Essential) { + if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) + { @:/// @:@WrapComment("/// ", String.IsNullOrEmpty(Model.Summary) ? Model.Description.EscapeXmlComment() : Model.Summary.EscapeXmlComment()) @:/// -} -@if (!String.IsNullOrEmpty(Model.Description) && !String.IsNullOrEmpty(Model.Summary)) -{ + } + if (!String.IsNullOrEmpty(Model.Description) && !String.IsNullOrEmpty(Model.Summary)) + { @:@WrapComment("/// ", Model.Description.EscapeXmlComment()) -} + } @:/// @:/// The operations group for this extension method. @:/// -foreach (var parameter in Model.LocalParameters) -{ + foreach (var parameter in Model.LocalParameters) + { @:/// @:@WrapComment("/// ", parameter.Documentation.EscapeXmlComment()) @:/// -} + } @:public static @Model.ReturnTypeString @(Model.Name)(@Model.GetExtensionParameters(Model.SyncMethodParameterDeclaration)) @:{ if (Model.ReturnType.Body != null) @@ -40,15 +42,16 @@ foreach (var parameter in Model.LocalParameters) @:Task.Factory.StartNew(s => ((I@(Model.MethodGroupName))s).@(Model.Name)Async(@(Model.SyncMethodInvocationArgs)), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); } @:} - @EmptyLine -@if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) +} + +if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) { @:/// @:@WrapComment("/// ", String.IsNullOrEmpty(Model.Summary) ? Model.Description.EscapeXmlComment() : Model.Summary.EscapeXmlComment()) @:/// } -@if (!String.IsNullOrEmpty(Model.Description) && !String.IsNullOrEmpty(Model.Summary)) +if (!String.IsNullOrEmpty(Model.Description) && !String.IsNullOrEmpty(Model.Summary)) { @:@WrapComment("/// ", Model.Description.EscapeXmlComment()) } @@ -95,26 +98,28 @@ foreach (var parameter in Model.LocalParameters) } @:} -@EmptyLine -@if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) +if (Model.SyncWrappers == SyncWrapperGenerationMode.All) { +@EmptyLine + if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) + { @:/// @:@WrapComment("/// ", String.IsNullOrEmpty(Model.Summary) ? Model.Description.EscapeXmlComment() : Model.Summary.EscapeXmlComment()) @:/// -} -@if (!String.IsNullOrEmpty(Model.Description) && !String.IsNullOrEmpty(Model.Summary)) -{ + } + if (!String.IsNullOrEmpty(Model.Description) && !String.IsNullOrEmpty(Model.Summary)) + { @:@WrapComment("/// ", Model.Description.EscapeXmlComment()) -} + } @:/// @:/// The operations group for this extension method. @:/// -foreach (var parameter in Model.LocalParameters) -{ + foreach (var parameter in Model.LocalParameters) + { @:/// @:@WrapComment("/// ", parameter.Documentation.EscapeXmlComment()) @:/// -} + } @:/// @:/// Headers that will be added to request. @:/// @@ -123,4 +128,5 @@ foreach (var parameter in Model.LocalParameters) @: return operations.@(Model.Name)WithHttpMessagesAsync(@(Model.GetAsyncMethodInvocationArgs("customHeaders", "CancellationToken.None"))).ConfigureAwait(false).GetAwaiter().GetResult(); @:} @: -} + } +} \ No newline at end of file From f04e04a8e014b3c230aac85797ca101cb702bdc5 Mon Sep 17 00:00:00 2001 From: Garrett Serack Date: Fri, 27 May 2016 13:12:47 -0700 Subject: [PATCH 20/23] Adding script to can verify that developer system has correct setup (#1098) * Adding script to can verify that developer system has correct setup * exclude empty paths in PATH from search --- README.md | 2 + Tools/Install-AndroidSDK.ps1 | 481 +++++++++++++++++++++++++++++++++++ Tools/verify-settings.ps1 | 279 ++++++++++++++++++++ 3 files changed, 762 insertions(+) create mode 100644 Tools/Install-AndroidSDK.ps1 create mode 100644 Tools/verify-settings.ps1 diff --git a/README.md b/README.md index 4886025019ae..f11e666641c2 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ AutoRest can be run on OSX and Unix using Mono or by running Docker container: ## Building AutoRest AutoRest is developed primarily in C# but generates code for multiple languages. See [this link](Documentation/building-code.md) to build and test AutoRest. +> Hint: There is a powershell script (`verify-settings.ps1`) in the `Tools` folder that can verify that you have the required compilers/tools/libraries installed on your development system before trying to build. + ## Hello World For this version of Hello World, we will use **AutoRest** to generate a client library and use it to call a web service. The trivial web service that just returns a string is defined as follows: ``` diff --git a/Tools/Install-AndroidSDK.ps1 b/Tools/Install-AndroidSDK.ps1 new file mode 100644 index 000000000000..b9b4944571b8 --- /dev/null +++ b/Tools/Install-AndroidSDK.ps1 @@ -0,0 +1,481 @@ +<# + This script can install additional Android SDK packages + (assuming that you installed at least something) + Gleefully borrowed from the VS 2015 installer. + + Usage: + + # Install the SDK for Android level 23: + # AS ADMIN!! + + .\Install-AndroidSDK.ps1 -RequestedAndroidPackages android-23 -apilevel 23 +#> +param +( + [String[]]$RequestedAndroidPackages, + [String]$Operation, + [String]$LogFileName, + [String]$APILevel +) + +function add-content( $path, $text ) { + write-host "LOG: $text" + Microsoft.PowerShell.Management\add-content $path $text +} + +function Set-InstallResult ($Succeeded, $details,$ReturnCode ) { + write-host $Succeeded $details $ReturnCode +} + +<# +Download and install Android SDK +#> +Function Invoke-InteractiveProcess([String]$FilePath, [string[]]$ArgumentList) +{ + $startInfo = New-Object System.Diagnostics.ProcessStartInfo + $startInfo.FileName = $FilePath + $startInfo.Arguments = $ArgumentList + $startInfo.UseShellExecute = $false + $startInfo.RedirectStandardInput = $true + $startInfo.RedirectStandardOutput = $true + $startInfo.CreateNoWindow = $true + $process = [System.Diagnostics.Process]::Start($startInfo) + + return $process +} + + +# Android helper functions +Function Get-AndroidHomeFromRegistry +{ + + # if ([Environment]::Is64BitOperatingSystem) + # powershell v1 doesn't have is 64 bit flag. + if ([environment]::GetEnvironmentVariable("ProgramFiles(x86)")) + { + $androidRegistryKey = "HKLM:\SOFTWARE\Wow6432Node\Android SDK Tools" + } + else + { + $androidRegistryKey = "HKLM:\SOFTWARE\Android SDK Tools" + } + + if (Test-Path $androidRegistryKey) + { + $path = (Get-ItemProperty $androidRegistryKey Path).Path + + if (-not (Test-Path $path)) + { + $path = $null + } + } + + return $path +} + + +Function Format-PackageList($packages) +{ + "$([Environment]::Newline) $($packages -join "$([Environment]::Newline) ")$([Environment]::Newline)" +} + +Function Get-AVDConfiguration([String]$FilePath) +{ + $result = @{} + + if (Test-Path $FilePath) + { + ForEach ($pair in (Get-Content $FilePath) -split "`n") + { + $pair = $pair -split "=" + + if ($pair.Count -eq 2) + { + $result[$pair[0]] = $pair[1] + } + } + } + + return $result +} + +Function Set-AVDConfiguration([String]$FilePath, [Hashtable]$configHashtable) +{ + Remove-Item $FilePath + + ForEach ($key in $configHashtable.Keys | Sort-Object) + { + $keyValuePair = "$key=$($configHashtable[$key])" + Add-Content $FilePath $keyValuePair + } +} + +Function Create-AVD([String]$Name, [String]$DeviceDefinition, [Hashtable]$ConfigurationOptions) +{ + if (-not $Name) + { + return + } + + add-content $logFile "Creating AVD $Name" + + $processArgs = @("create avd", + "-n $Name", + "-t $currentApiLevel", + "-b default/armeabi-v7a") + + if ($DeviceDefinition) + { + $processArgs += "-d `"$DeviceDefinition`"" + } + + # Create the AVD + $process = Invoke-InteractiveProcess ` + -FilePath "$androidHome\tools\android.bat" ` + -ArgumentList $processArgs + + while (-not $process.StandardOutput.EndOfStream) + { + # Answer 'no' to: Do you wish to create a custom hardware profile [no] + $firstChar = $process.StandardOutput.Peek() + if ($firstChar -eq 68) + { + $process.StandardInput.WriteLine("no") + } + + $line = $process.StandardOutput.ReadLine() + + add-content $logFile "$line$([Environment]::NewLine)" + } + + # needs to kill adb process here because if SecondaryInstaller is launched via ARP, adb + # server will be launched and prevent ARP from installing other things. + # need to have -erroraction silentlycontinue, otherwise we'll get an error when adb doesn't exist + $processAdb = Get-Process adb -erroraction silentlycontinue + if ($processAdb) + { + $processAdb.Kill() + } + if (!$process.HasExited) + { + $process.CloseMainWindow() + } + $process.Dispose() + + $avdConfigFile = "$env:HOMEPATH\.android\avd\$defaultAVDName.avd\config.ini" + + if (Test-Path $avdConfigFile) + { + $configHashtable = Get-AVDConfiguration $avdConfigFile + + foreach ($key in $ConfigurationOptions.Keys) + { + $configHashtable[$key] = $ConfigurationOptions[$key] + } + + Set-AVDConfiguration $avdConfigFile $configHashtable + + add-content $logFile "Updating AVD $Name to the following hardware config:$([Environment]::NewLine)" + + Get-Content $avdConfigFile | Microsoft.PowerShell.Management\add-content $logFile + + add-content $logFile "$([Environment]::NewLine)" + } +} + +Function Get-DeviceDefinitionNames() +{ + return (& $androidBatch list devices) ` + | Select-String ` + -AllMatches ` + -Pattern 'id: (?\d+) or "(?[\s-_A-Za-z0-9\.]+)"' ` + | Select-Object -ExpandProperty Matches ` + | Foreach-Object {$_.Groups['deviceName'].Value} +} + +Function Get-PreferredAVDDeviceDefinition() +{ + $nexusDevices = Get-DeviceDefinitionNames | Where-Object { $_.Contains("Nexus")} + + $deviceDefinition = "" + $preferredDeviceDefinition = "Galaxy Nexus" + + if ($nexusDevices.Length -gt 0) + { + if ($nexusDevices -contains $preferredDeviceDefinition) + { + $deviceDefinition = $preferredDeviceDefinition + } + else + { + $deviceDefinition = $nexusDevices[0] + } + } + + return $deviceDefinition +} + +Function Get-FileNameWithTimeStamp([String]$OldFileName) +{ + [string]$strippedFileName = [System.IO.Path]::GetFileNameWithoutExtension($OldFileName); + [string]$extension = [System.IO.Path]::GetExtension($OldFileName); + [string]$newFileName = $strippedFileName + [DateTime]::Now.ToString("yyyyMMdd-HHmmss") + $extension; + [string]$newFilePath = [System.IO.Path]::Combine($Env:temp, $newFileName); + + return $newFilePath +} + +# OUTPUT: [String[]]A list of packages installed previously. +# Operation: +# Go to HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AndroidSDKSelector +# Extract the list of key names. +Function Get-InstalledPackagesFromRegistry() +{ + [String[]]$installedPackagesResult = @() + + $androidPackageSelectorRootRegistryKey = "HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AndroidSDKSelector" + + if (Test-Path $androidPackageSelectorRootRegistryKey) + { + $installedPackagesItems = Get-ChildItem $androidPackageSelectorRootRegistryKey -ErrorAction SilentlyContinue + + $installedPackagesResult = $installedPackagesItems | Select-Object -ExpandProperty PSChildName + } + + return $installedPackagesResult +} + +# INPUT: TargetPackages - a list of packages the user wants to install. +# INPUT: TargetOperation - the current operation. +# OUTPUT: A list of packages the script should install. +# Operation: +# If the TargetOperation is Repair and no TargetPackages is passed in return a list of alreadyInstalledPackages. +# Else +# Return a list of TargetPackages that are not already been installed. +Function Get-DesiredPackages([String[]]$TargetPackages, [String]$TargetOperation) +{ + $alreadyInstalledPackages = Get-InstalledPackagesFromRegistry + + add-content $logFile "Here are list of packages already installed on this system: $alreadyInstalledPackages" + + if ($TargetOperation -eq "Repair") + { + # if the user pass in specific packages, then we should repair those. + if ($TargetPackages) + { + add-content $logFile "Repair the following: $TargetPackages" + return $TargetPackages + } + + add-content $logFile "Repair the following: $alreadyInstalledPackages" + + return $alreadyInstalledPackages + } + + $packagesDontNeedToBeInstalled = $TargetPackages | Where { $alreadyInstalledPackages -contains $_ } + add-content $logFile "Skipping followings because they were installed previously: $packagesDontNeedToBeInstalled" + $packagesNeedToBeInstalled = $TargetPackages | Where { $alreadyInstalledPackages -notcontains $_ } + Add-Content $logFile "Install the followings: $packagesNeedToBeInstalled" + + return $packagesNeedToBeInstalled +} + +# INPUT: TargetPackages - a list of packages that were installed successfully. +# INPUT: TargetOperation - the current operation. +# Operation: +# If the TargetOperation is Repair, no opt. +# Else +# Write a list of intalled packages to the registry. +Function Set-InstalledPackages([String[]]$InstalledPackages, [String]$TargetOperation) +{ + if ($TargetOperation -eq "Repair") + { + add-content $logFile "Repair operation, no registry is set." + } + else + { + add-content $logFile "Recording the list of installed package. (This step will not remove previously installed items)" + + foreach($p in $InstalledPackages) + { + $androidPackageSelectorRegistryKey = "HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AndroidSDKSelector\$p" + + add-content $logFile "Recorded Installed item: $androidPackageSelectorRegistryKey" + + if (-not (Test-Path $androidPackageSelectorRegistryKey)) + { + $newRegistryItem = New-Item -Force -Path $androidPackageSelectorRegistryKey -ErrorAction SilentlyContinue + } + } + } +} + +# INPUT: +# [String[]]$RequestedAndroidPackages, +# [String]$Operation, +# [String]$LogFileName, +# [Int]$APILevel + +# Get Start Time +$startDTM = (Get-Date) + +$logFile = Get-FileNameWithTimeStamp $LogFileName +if ([IO.File]::Exists($logFile)) +{ + Remove-Item $logFile +} + +add-content $logFile "AndroidSDKInstall: -RequestedAndroidPackages $RequestedAndroidPackages -Operation $Operation -LogFilename $LogFileName -APILevel $APILevel" +add-content $logFile "Android SDK Install starting ..." + +$androidHome = Get-AndroidHomeFromRegistry + +# if androidHome doesn't exist then we don't have to select products. +if (!$androidHome) +{ + add-content $logFile "No Android SDK detected." + + Set-InstallResult -Succeeded $true + exit +} + +add-content $logFile "AndroidHome:" +add-content $logFile $androidHome + +$androidBatch = Join-Path $androidHome "tools\android.bat" + +$packageListingOutputRaw = & $androidBatch list sdk --all --extended +$anyAVDsFound = (& $androidBatch list avd) -match "Name: " + +$packageRegex = 'id: \d+ or "(?[-_A-Za-z0-9\.]+)"' +$availablePackages = [regex]::Matches($packageListingOutputRaw, $packageRegex) | ForEach { $_.Groups["packageName"].Value } + +add-content $logFile "Android packages available:" +add-content $logFile "$(Format-PackageList $availablePackages)" + +Add-Content $logFile "Requested Packages: $RequestedAndroidPackages" + +$desiredPackages = Get-DesiredPackages $RequestedAndroidPackages $Operation + +$currentApiLevel = $APILevel + +$packagesToInstall = $desiredPackages | Where { $availablePackages -contains $_ } +$packagesNotFound = $desiredPackages | Where { $availablePackages -notcontains $_ } + +if ($packagesToInstall) +{ + add-content $logFile "Installing packages:" + add-content $logFile "$(Format-PackageList $packagesToInstall)" + + $process = Invoke-InteractiveProcess ` + -FilePath "$androidHome\tools\android.bat" ` + -ArgumentList @("update sdk", + "-u", + "-a", + "--filter $($packagesToInstall -join ",")") + + $newLine = '' + while (-not $process.StandardOutput.EndOfStream) + { + # we need to read one char at a time, and when we encounter newline, then we pipe it out as output. + $rawVal = $process.StandardOutput.Read() + + if ($rawVal -eq -1) + { + break; + } + + $oneChar = [char]$rawVal + + # check for new line. + if ($rawVal -eq 10) + { + add-content $logFile "$newLine$([Environment]::NewLine)" + $newLine = '' + } + else + { + $newLine = $newLine + $oneChar + + if ($newLine -match 'Done. \d+ packages installed.') + { + break + } + + # if it match the sentenses + if ($newLine.StartsWith("Do you accept the license", "InvariantCultureIgnoreCase")) + { + $process.StandardInput.WriteLine("y") + + # read the remainder of the line. + $remainder = $process.StandardOutput.ReadLine(); + add-content $logFile "$newLine$remainder" + $newLine = '' + } + if ($newLine.StartsWith("A folder failed to be moved.", "InvariantCultureIgnoreCase")) + { + $process.StandardInput.WriteLine("n") + + # read the remaider of the line. + $remainder = $process.StandardOutput.ReadLine(); + add-content $logFile "$newLine$remainder" + $newLine = '' + + Set-InstallResult -Succeeded $false -Details The process cannot access the file because another process has locked a portion of the file. -ReturnCode 33 + exit + } + } + } + + # needs to kill adb process here because if SecondaryInstaller is launched via ARP, adb + # server will be launched and prevent ARP from installing other things. + # need to have -erroraction silentlycontinue, otherwise we'll get an error when adb doesn't exist + $processAdb = Get-Process adb -erroraction silentlycontinue + if ($processAdb) + { + $processAdb.Kill() + } + if (!$process.HasExited) + { + $process.CloseMainWindow() + } + $process.Dispose() +} + +# If there aren't any AVDs present on the system create one. +if (-not $anyAVDsFound) +{ + $deviceDefinition = Get-PreferredAVDDeviceDefinition + + if ($deviceDefinition -and $currentApiLevel) + { + $defaultAVDName = "AVD_$($deviceDefinition -replace ' ', '')_ToolsForApacheCordova" + + Create-AVD ` + -Name $defaultAVDName ` + -DeviceDefinition $deviceDefinition ` + -ConfigurationOptions @{"hw.keyboard" = "yes"; + "hw.ramSize" = "768"; + "vm.heapSize" = "64"} + } +} + +if ($packagesNotFound) +{ + add-content $logFile "WARNING: The following package(s) were not found:" + add-content $logFile "$(Format-PackageList $packagesNotFound)" + + # return code ERROR_BAD_NETPATH 53 + Set-InstallResult -Succeeded $false -Details "The following package(s) were not downloaded: $packagesNotFound . Please check your internet connection and try again." -ReturnCode 53 + exit +} + +Set-InstalledPackages $packagesToInstall $Operation + +add-content $logFile "Android SDK Install is successful." + +# Get End Time +$endDTM = (Get-Date) +add-content $logFile "Elapsed Time: $(($endDTM-$startDTM).totalseconds) seconds" + +Set-InstallResult -Succeeded $true diff --git a/Tools/verify-settings.ps1 b/Tools/verify-settings.ps1 new file mode 100644 index 000000000000..bb419ddebaf6 --- /dev/null +++ b/Tools/verify-settings.ps1 @@ -0,0 +1,279 @@ +<# + This script attempts to find the tools required to build Autorest, and + if necessary sets the required environment variables and PATH settings + (in the current process) + + When finding a tool, it scans the PATH, then can look recursively in folders + for the tools. + + When it finds a tool, it will remember it by sticking an entry into the + registry. + + -reset will nuke the remembered tools. +#> + +param ( + [Switch] $reset # will nuke the remembered tools. + ) + +if( $reset ) { + rmdir -recurse -force -ea 0 "HKCU:\Software\KnownTools" +} + +function exists($file) { + return ($file -and (test-path -PathType Leaf $file )) +} + +function Read-PEHeader ($exe) { + if( exists $exe ) { + try { + [byte[]]$data = New-Object -TypeName System.Byte[] -ArgumentList 4096 + $stream = New-Object -TypeName System.IO.FileStream -ArgumentList ($exe, 'Open', 'Read') + $stream.Read($data, 0, 4096) | Out-Null + } finally { + $stream.Close(); + } + return $data; + } +} + +function Get-Architecture ($exe) { + $data = Read-PEHeader $exe + if( $data -and ([System.BitConverter]::ToInt16($data,0) -eq 23117 )) { + [int32]$MACHINE_OFFSET = 4 + [int32]$PE_POINTER_OFFSET = 60 + [int32]$PE_HEADER_ADDR = [System.BitConverter]::ToInt32($data, $PE_POINTER_OFFSET) + + switch ([System.BitConverter]::ToUInt16($data, $PE_HEADER_ADDR + $MACHINE_OFFSET)) { + 0 { return 'Native' } + 0x014c { return 'x86' } + 0x0200 { return 'Itanium' } + 0x8664 { return 'x64' } + } + } + return 'Unknown' +} + +function Any { + [CmdletBinding()] + param( [Parameter(Mandatory = $True)] $Condition, [Parameter(Mandatory = $True, ValueFromPipeline = $True)] $Item ) + begin { $isMatch = $False } + process { if (& $Condition $Item) { $isMatch = $true } } + end { $isMatch } +} + +function All { + [CmdletBinding()] + param( [Parameter(Mandatory = $True)] $Condition, [Parameter(Mandatory = $True, ValueFromPipeline = $True)] $Item ) + begin { $isMatch = $true } + process { if (-not ($isMatch -and (& $Condition $Item)) ) {$isMatch = $false} } + end { $isMatch } +} + +function Includes { param( [string] $i, [string[]] $all ) $all | All { $i -match $_ } } +function Excludes { param( [string] $i, [string[]] $all ) $all | All { -not ($i -match $_) } } + +function Validate ( + [string] $exe, + [string] $arch, + [string[]] $include, + [string[]] $exclude, + [string] $minimumVersion ) { + + if(exists $exe ) { + $file = dir $exe + + if( -not (Includes $file $include) ) { + return $false + } + + if( -not (Excludes $file $exclude) ) { + return $false + } + + if( $arch -and $arch -ne (Get-Architecture $file) ) { + return $false + } + + if( $minimumVersion -and (([system.version]$minimumVersion) -gt $file.VersionInfo.FileVersion ) ) { + return $false + } + + return $file + } + return $false +} + +function which( + [string]$cmd, + [string]$arch, + [string[]] $include = @(), + [string[]] $exclude= @('arm','_x86','x86_', 'shared'), + [string] $minimumVersion = $null) { + + if( $env:path ) { + foreach( $dir in $env:path.Split(";")) { + foreach( $ext in (";.ps1;"+$env:pathext).split(";")) { + if( $dir -and (resolve-path $dir) ) { + $p = join-path $dir "$cmd$ext" + if( exists $p ) { + if( Validate -exe $p $arch $include $exclude $minimumVersion ) { + return (dir $p) + } + } + } + } + } + } +} + +function find-exe ( + [string] $exe, + [string] $arch, + [string[]] $folders = @("${env:ProgramFiles(x86)}","${env:ProgramFiles}"), + [string[]] $include = @(), + [string[]] $exclude= @('arm','_x86','x86_','shared'), + [string] $minimumVersion = $null + ) { + + # find exe on path + $result = which $exe $arch $include $exclude $minimumVersion + if( $result ) { + return $result + } + + # not in path. check registry + $kt = "HKCU:\Software\KnownTools" + if( $arch ) { + $kt += "\$arch" + } + + if( $minimumVersion ) { + $kt += "\$minimumVersion" + try { $minimumVersion = [system.version]$minimumVersion } catch { + try { + $minimumVersion = [system.version]($minimumVersion + ".0") + } catch { + write-error "Bad Version $minimumVersion" + return; + } + } + } + + if( $result = Validate -exe ((Get-ItemProperty -Path "$kt\$exe" -Name Path -ea 0).Path) $arch $include $exclude $minimumVersion) { + return $result + } + + if( -not $result -or -not (exists $result )) { + write-host -fore yellow "Searching for $exe" + $result = ($folders |% {cmd "/c dir /s/b `"$_\$exe`" 2>nul" | dir }) ` + |% { Validate -exe $_ $arch $include $exclude $minimumVersion } ` + |? { $_ -ne $false } ` + | Sort-Object -Descending { $_.VersionInfo.FileVersion } ` + | Select-Object -first 1 + + if( $result ) { + $result = $result.FullName + $null = mkdir -Path "$kt\$exe" -Force + $null = New-ItemProperty -Path "$kt\$exe" -Name Path -Value $result -force + } + } + if( $result ) { + return (dir $result) + } +} + +$failing = $false + +function Find-OrAdd ( $cmd , $folders = @("${env:ProgramFiles(x86)}","${env:ProgramFiles}"), $hint = $null ) { + if( !($exe = which $cmd) ) { + $exe = find-exe $cmd -folders $folders + if( $exe) { + write-host "Adding '$($exe.Directory)' to PATH". + # $env:PATH="$env:PATH;$($exe.Directory)" + $env:PATH="$($exe.Directory);$env:PATH" + } else { + write-host -fore red "Unable to find '$cmd' in path/search folders" + if( $hint ) { + write-host -fore yellow "HINT: $hint" + } + $script:failing = $true + + } + } +} + +Function Get-AndroidHomeFromRegistry +{ + # if ([Environment]::Is64BitOperatingSystem) + # powershell v1 doesn't have is 64 bit flag. + if ([environment]::GetEnvironmentVariable("ProgramFiles(x86)")) + { + $androidRegistryKey = "HKLM:\SOFTWARE\Wow6432Node\Android SDK Tools" + } + else + { + $androidRegistryKey = "HKLM:\SOFTWARE\Android SDK Tools" + } + + if (Test-Path $androidRegistryKey) + { + $path = (Get-ItemProperty $androidRegistryKey Path).Path + + if (-not (Test-Path $path)) + { + $path = $null + } + } + + return $path +} + +find-orAdd "dotnet.exe" -hint "See: https://www.microsoft.com/net/core#windows" +find-orAdd "msbuild.exe" -hint "Install Visual studio 2015" + +find-orAdd "javac.exe" -hint "Download and install JAVA JDK" + +find-orAdd "node.exe" -hint "See: https://nodejs.org" +find-orAdd "gulp.cmd" -hint "maybe use 'npm install -g gulp'" + +find-orAdd "ruby.exe" (@() + ((dir -ea 0 c:\ruby*).fullname) + @( "${env:ProgramFiles(x86)}","${env:ProgramFiles}","c:\tools")) -hint "see http://rubyinstaller.org/downloads/" + +find-orAdd "gradle.bat" ( @( "${env:ProgramFiles(x86)}","${env:ProgramFiles}","c:\tools")) -hint "see http://gradle.org/gradle-download/" + +find-orAdd "python.exe" (@() + ((dir -ea 0 c:\python*).fullname) + @( "${env:ProgramFiles(x86)}","${env:ProgramFiles}","c:\tools")) -hint "https://www.python.org/downloads/" +find-orAdd "tox.exe" (@() + ((dir -ea 0 c:\python*).fullname) + @( "${env:ProgramFiles(x86)}","${env:ProgramFiles}","c:\tools")) -hint "maybe use 'pip install tox'" + + +# + +# make sure JAVA_HOME is set +if( (!$env:JAVA_HOME) -or (!(test-path -PathType Container $env:JAVA_HOME )) ) { + $javac = which javac.exe + if( $javac ) { + $env:JAVA_HOME = (get-item ("$javac\..\..")) + write-host "Setting JAVA_HOME to $ENV:JAVA_HOME". + } else { + write-host -fore red "Environment variable JAVA_HOME not set correctly." + $failing = $true + } +} + +# use this to add the missing SDK +# .\Install-AndroidSDK.ps1 -RequestedAndroidPackages android-23 -apilevel 23 + +if( (!$env:ANDROID_HOME) -or (!(test-path -PathType Container $env:ANDROID_HOME )) ) { + $android = Get-AndroidHomeFromRegistry + if (! $android ) { + write-host -fore red "Environment variable ANDROID_HOME not set correctly." + $failing = $true + } else { + $env:ANDROID_HOME= $android + } +} + +if( !$failing ) { + write-host -fore green "`n`nTools/Environment are OK" +} else { + write-host -fore red "`n`nTools/Environment are not OK" +} From e6f05e85721d340a54327f259e08fad717a8c301 Mon Sep 17 00:00:00 2001 From: stankovski Date: Fri, 27 May 2016 15:09:32 -0700 Subject: [PATCH 21/23] Added tests --- AutoRest/AutoRest.Core/Settings.cs | 4 + .../AutoRestDurationTestService.cs | 287 ++ .../DurationOperations.cs | 625 +++++ .../DurationOperationsExtensions.cs | 197 ++ .../IAutoRestDurationTestService.cs | 70 + .../IDurationOperations.cs | 68 + .../AzureBodyDurationAllSync/Models/Error.cs | 46 + .../Models/ErrorException.cs | 99 + .../AutoRestDurationTestService.cs | 287 ++ .../DurationOperations.cs | 625 +++++ .../DurationOperationsExtensions.cs | 93 + .../IAutoRestDurationTestService.cs | 70 + .../IDurationOperations.cs | 68 + .../AzureBodyDurationNoSync/Models/Error.cs | 46 + .../Models/ErrorException.cs | 99 + .../Azure.CSharp/AzureCSharpCodeGenerator.cs | 4 +- .../AzureExtensionsTemplateModel.cs | 2 +- .../AzureMethodGroupTemplateModel.cs | 2 +- .../AzureMethodTemplateModel.cs | 4 +- .../AzureServiceClientTemplateModel.cs | 2 +- .../CSharp/CSharp.Tests/AcceptanceTests.cs | 16 + .../PetstoreV2AllSync/ISwaggerPetstoreV2.cs | 335 +++ .../PetstoreV2AllSync/Models/ApiResponse.cs | 51 + .../PetstoreV2AllSync/Models/Category.cs | 45 + .../Models/LoginUserHeaders.cs | 50 + .../PetstoreV2AllSync/Models/Order.cs | 71 + .../Expected/PetstoreV2AllSync/Models/Pet.cs | 103 + .../Expected/PetstoreV2AllSync/Models/Tag.cs | 45 + .../Expected/PetstoreV2AllSync/Models/User.cs | 82 + .../PetstoreV2AllSync/SwaggerPetstoreV2.cs | 2331 +++++++++++++++++ .../SwaggerPetstoreV2Extensions.cs | 1033 ++++++++ .../PetstoreV2NoSync/ISwaggerPetstoreV2.cs | 335 +++ .../PetstoreV2NoSync/Models/ApiResponse.cs | 51 + .../PetstoreV2NoSync/Models/Category.cs | 45 + .../Models/LoginUserHeaders.cs | 50 + .../Expected/PetstoreV2NoSync/Models/Order.cs | 71 + .../Expected/PetstoreV2NoSync/Models/Pet.cs | 103 + .../Expected/PetstoreV2NoSync/Models/Tag.cs | 45 + .../Expected/PetstoreV2NoSync/Models/User.cs | 82 + .../PetstoreV2NoSync/SwaggerPetstoreV2.cs | 2331 +++++++++++++++++ .../SwaggerPetstoreV2Extensions.cs | 398 +++ .../CSharp/AutoRest.Generator.CSharp.csproj | 2 +- .../CSharp/CSharp/CSharpCodeGenerator.cs | 7 +- ...onMode.cs => SyncMethodsGenerationMode.cs} | 2 +- .../TemplateModels/ExtensionsTemplateModel.cs | 2 +- .../MethodGroupTemplateModel.cs | 2 +- .../TemplateModels/MethodTemplateModel.cs | 6 +- .../ServiceClientTemplateModel.cs | 2 +- .../Templates/ExtensionMethodTemplate.cshtml | 10 +- Tools/gulp/gulp-regenerate-expected.js | 7 +- gulpfile.js | 76 +- 51 files changed, 10461 insertions(+), 26 deletions(-) create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/AutoRestDurationTestService.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperationsExtensions.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestService.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IDurationOperations.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/Error.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/ErrorException.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestService.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperationsExtensions.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestService.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IDurationOperations.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/Error.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/ErrorException.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2Extensions.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs create mode 100644 AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2Extensions.cs rename AutoRest/Generators/CSharp/CSharp/{SyncWrapperGenerationMode.cs => SyncMethodsGenerationMode.cs} (89%) diff --git a/AutoRest/AutoRest.Core/Settings.cs b/AutoRest/AutoRest.Core/Settings.cs index df99585e02d3..94c9fb7f524d 100644 --- a/AutoRest/AutoRest.Core/Settings.cs +++ b/AutoRest/AutoRest.Core/Settings.cs @@ -309,6 +309,10 @@ public static void PopulateSettings(object entityToPopulate, IDictionary + /// Test Infrastructure for AutoRest + /// + public partial class AutoRestDurationTestService : ServiceClient, IAutoRestDurationTestService, IAzureClient + { + /// + /// The base URI of the service. + /// + public Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Gets Azure subscription credentials. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// Gets or sets the preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// Gets or sets the retry timeout in seconds for Long Running Operations. + /// Default value is 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// When set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IDurationOperations. + /// + public virtual IDurationOperations Duration { get; private set; } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(params DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.Duration = new DurationOperations(this); + this.BaseUri = new Uri("https://localhost"); + this.AcceptLanguage = "en-US"; + this.LongRunningOperationRetryTimeout = 30; + this.GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs new file mode 100644 index 000000000000..81ec07668d7d --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs @@ -0,0 +1,625 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationAllSync +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using Microsoft.Rest.Azure; + using Models; + + /// + /// DurationOperations operations. + /// + internal partial class DurationOperations : IServiceOperations, IDurationOperations + { + /// + /// Initializes a new instance of the DurationOperations class. + /// + /// + /// Reference to the service client. + /// + internal DurationOperations(AutoRestDurationTestService client) + { + if (client == null) + { + throw new ArgumentNullException("client"); + } + this.Client = client; + } + + /// + /// Gets a reference to the AutoRestDurationTestService + /// + public AutoRestDurationTestService Client { get; private set; } + + /// + /// Get null duration value + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetNullWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetNull", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/null").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.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; + } + + /// + /// Put a positive duration value + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task PutPositiveDurationWithHttpMessagesAsync(TimeSpan durationBody, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("durationBody", durationBody); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "PutPositiveDuration", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/positiveduration").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + _requestContent = SafeJsonConvert.SerializeObject(durationBody, this.Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a positive duration value + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetPositiveDurationWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPositiveDuration", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/positiveduration").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get an invalid duration value + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetInvalidWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetInvalid", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/invalid").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.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; + } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperationsExtensions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperationsExtensions.cs new file mode 100644 index 000000000000..6a135327c6c5 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperationsExtensions.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationAllSync +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Extension methods for DurationOperations. + /// + public static partial class DurationOperationsExtensions + { + /// + /// Get null duration value + /// + /// + /// The operations group for this extension method. + /// + public static TimeSpan? GetNull(this IDurationOperations operations) + { + return Task.Factory.StartNew(s => ((IDurationOperations)s).GetNullAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get null duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetNullAsync(this IDurationOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetNullWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get null duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// Headers that will be added to request. + /// + public static AzureOperationResponse GetNullWithHttpMessages(this IDurationOperations operations, Dictionary> customHeaders = null) + { + return operations.GetNullWithHttpMessagesAsync(customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Put a positive duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// + public static void PutPositiveDuration(this IDurationOperations operations, TimeSpan durationBody) + { + Task.Factory.StartNew(s => ((IDurationOperations)s).PutPositiveDurationAsync(durationBody), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Put a positive duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task PutPositiveDurationAsync(this IDurationOperations operations, TimeSpan durationBody, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.PutPositiveDurationWithHttpMessagesAsync(durationBody, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Put a positive duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// + /// + /// Headers that will be added to request. + /// + public static AzureOperationResponse PutPositiveDurationWithHttpMessages(this IDurationOperations operations, TimeSpan durationBody, Dictionary> customHeaders = null) + { + return operations.PutPositiveDurationWithHttpMessagesAsync(durationBody, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Get a positive duration value + /// + /// + /// The operations group for this extension method. + /// + public static TimeSpan? GetPositiveDuration(this IDurationOperations operations) + { + return Task.Factory.StartNew(s => ((IDurationOperations)s).GetPositiveDurationAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a positive duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetPositiveDurationAsync(this IDurationOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPositiveDurationWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a positive duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// Headers that will be added to request. + /// + public static AzureOperationResponse GetPositiveDurationWithHttpMessages(this IDurationOperations operations, Dictionary> customHeaders = null) + { + return operations.GetPositiveDurationWithHttpMessagesAsync(customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Get an invalid duration value + /// + /// + /// The operations group for this extension method. + /// + public static TimeSpan? GetInvalid(this IDurationOperations operations) + { + return Task.Factory.StartNew(s => ((IDurationOperations)s).GetInvalidAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get an invalid duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetInvalidAsync(this IDurationOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetInvalidWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get an invalid duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// Headers that will be added to request. + /// + public static AzureOperationResponse GetInvalidWithHttpMessages(this IDurationOperations operations, Dictionary> customHeaders = null) + { + return operations.GetInvalidWithHttpMessagesAsync(customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestService.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestService.cs new file mode 100644 index 000000000000..827a67fffa7b --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestService.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationAllSync +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Test Infrastructure for AutoRest + /// + public partial interface IAutoRestDurationTestService : IDisposable + { + /// + /// The base URI of the service. + /// + Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Gets Azure subscription credentials. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// Gets or sets the preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// Gets or sets the retry timeout in seconds for Long Running + /// Operations. Default value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// When set to true a unique x-ms-client-request-id value is + /// generated and included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IDurationOperations. + /// + IDurationOperations Duration { get; } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IDurationOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IDurationOperations.cs new file mode 100644 index 000000000000..08caf84df02c --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IDurationOperations.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationAllSync +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// DurationOperations operations. + /// + public partial interface IDurationOperations + { + /// + /// Get null duration value + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetNullWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Put a positive duration value + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task PutPositiveDurationWithHttpMessagesAsync(TimeSpan durationBody, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a positive duration value + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetPositiveDurationWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get an invalid duration value + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetInvalidWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/Error.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/Error.cs new file mode 100644 index 000000000000..5a2d8bfa1c65 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/Error.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationAllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Microsoft.Rest.Azure; + + public partial class Error + { + /// + /// Initializes a new instance of the Error class. + /// + public Error() { } + + /// + /// Initializes a new instance of the Error class. + /// + public Error(int? status = default(int?), string message = default(string)) + { + Status = status; + Message = message; + } + + /// + /// + [JsonProperty(PropertyName = "status")] + public int? Status { get; set; } + + /// + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/ErrorException.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/ErrorException.cs new file mode 100644 index 000000000000..8b02d920b472 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/Models/ErrorException.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationAllSync.Models +{ + using Microsoft.Rest; + using System; + using System.Net.Http; + using System.Runtime.Serialization; +#if !PORTABLE + using System.Security.Permissions; +#endif + + /// + /// Exception thrown for an invalid response with Error information. + /// +#if !PORTABLE + [Serializable] +#endif + public class ErrorException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public Error Body { get; set; } + + /// + /// Initializes a new instance of the ErrorException class. + /// + public ErrorException() + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + public ErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + /// Inner exception. + public ErrorException(string message, Exception innerException) + : base(message, innerException) + { + } + +#if !PORTABLE + /// + /// Initializes a new instance of the ErrorException class. + /// + /// Serialization info. + /// Streaming context. + protected ErrorException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + /// + /// Serializes content of the exception. + /// + /// Serialization info. + /// Streaming context. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + if (info == null) + { + throw new ArgumentNullException("info"); + } + + info.AddValue("Request", Request); + info.AddValue("Response", Response); + info.AddValue("Body", Body); + } +#endif + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestService.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestService.cs new file mode 100644 index 000000000000..8adef14be4bb --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestService.cs @@ -0,0 +1,287 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationNoSync +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Diagnostics; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Test Infrastructure for AutoRest + /// + public partial class AutoRestDurationTestService : ServiceClient, IAutoRestDurationTestService, IAzureClient + { + /// + /// The base URI of the service. + /// + public Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Gets Azure subscription credentials. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// Gets or sets the preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// Gets or sets the retry timeout in seconds for Long Running Operations. + /// Default value is 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// When set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IDurationOperations. + /// + public virtual IDurationOperations Duration { get; private set; } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(params DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AutoRestDurationTestService(Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the AutoRestDurationTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Gets Azure subscription credentials. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestDurationTestService(Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.Duration = new DurationOperations(this); + this.BaseUri = new Uri("https://localhost"); + this.AcceptLanguage = "en-US"; + this.LongRunningOperationRetryTimeout = 30; + this.GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs new file mode 100644 index 000000000000..44b091050b15 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs @@ -0,0 +1,625 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationNoSync +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using Microsoft.Rest.Azure; + using Models; + + /// + /// DurationOperations operations. + /// + internal partial class DurationOperations : IServiceOperations, IDurationOperations + { + /// + /// Initializes a new instance of the DurationOperations class. + /// + /// + /// Reference to the service client. + /// + internal DurationOperations(AutoRestDurationTestService client) + { + if (client == null) + { + throw new ArgumentNullException("client"); + } + this.Client = client; + } + + /// + /// Gets a reference to the AutoRestDurationTestService + /// + public AutoRestDurationTestService Client { get; private set; } + + /// + /// Get null duration value + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetNullWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetNull", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/null").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.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; + } + + /// + /// Put a positive duration value + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task PutPositiveDurationWithHttpMessagesAsync(TimeSpan durationBody, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("durationBody", durationBody); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "PutPositiveDuration", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/positiveduration").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + _requestContent = SafeJsonConvert.SerializeObject(durationBody, this.Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a positive duration value + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetPositiveDurationWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPositiveDuration", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/positiveduration").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get an invalid duration value + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetInvalidWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetInvalid", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/invalid").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.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; + } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperationsExtensions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperationsExtensions.cs new file mode 100644 index 000000000000..d71b17b8310b --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperationsExtensions.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationNoSync +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Extension methods for DurationOperations. + /// + public static partial class DurationOperationsExtensions + { + /// + /// Get null duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetNullAsync(this IDurationOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetNullWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Put a positive duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task PutPositiveDurationAsync(this IDurationOperations operations, TimeSpan durationBody, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.PutPositiveDurationWithHttpMessagesAsync(durationBody, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a positive duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetPositiveDurationAsync(this IDurationOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPositiveDurationWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get an invalid duration value + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetInvalidAsync(this IDurationOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetInvalidWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestService.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestService.cs new file mode 100644 index 000000000000..fa77d214b339 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestService.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationNoSync +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Test Infrastructure for AutoRest + /// + public partial interface IAutoRestDurationTestService : IDisposable + { + /// + /// The base URI of the service. + /// + Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Gets Azure subscription credentials. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// Gets or sets the preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// Gets or sets the retry timeout in seconds for Long Running + /// Operations. Default value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// When set to true a unique x-ms-client-request-id value is + /// generated and included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IDurationOperations. + /// + IDurationOperations Duration { get; } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IDurationOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IDurationOperations.cs new file mode 100644 index 000000000000..128a7a4cea18 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IDurationOperations.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationNoSync +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// DurationOperations operations. + /// + public partial interface IDurationOperations + { + /// + /// Get null duration value + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetNullWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Put a positive duration value + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task PutPositiveDurationWithHttpMessagesAsync(TimeSpan durationBody, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a positive duration value + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetPositiveDurationWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get an invalid duration value + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetInvalidWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/Error.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/Error.cs new file mode 100644 index 000000000000..6a0e0f606f12 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/Error.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationNoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Microsoft.Rest.Azure; + + public partial class Error + { + /// + /// Initializes a new instance of the Error class. + /// + public Error() { } + + /// + /// Initializes a new instance of the Error class. + /// + public Error(int? status = default(int?), string message = default(string)) + { + Status = status; + Message = message; + } + + /// + /// + [JsonProperty(PropertyName = "status")] + public int? Status { get; set; } + + /// + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/ErrorException.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/ErrorException.cs new file mode 100644 index 000000000000..1902b5496c33 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/Models/ErrorException.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsAzureBodyDurationNoSync.Models +{ + using Microsoft.Rest; + using System; + using System.Net.Http; + using System.Runtime.Serialization; +#if !PORTABLE + using System.Security.Permissions; +#endif + + /// + /// Exception thrown for an invalid response with Error information. + /// +#if !PORTABLE + [Serializable] +#endif + public class ErrorException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public Error Body { get; set; } + + /// + /// Initializes a new instance of the ErrorException class. + /// + public ErrorException() + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + public ErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + /// Inner exception. + public ErrorException(string message, Exception innerException) + : base(message, innerException) + { + } + +#if !PORTABLE + /// + /// Initializes a new instance of the ErrorException class. + /// + /// Serialization info. + /// Streaming context. + protected ErrorException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + /// + /// Serializes content of the exception. + /// + /// Serialization info. + /// Streaming context. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + if (info == null) + { + throw new ArgumentNullException("info"); + } + + info.AddValue("Request", Request); + info.AddValue("Response", Response); + info.AddValue("Body", Body); + } +#endif + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs b/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs index 85f9fe326a90..c2fa13de5ca2 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs @@ -99,7 +99,7 @@ public override async Task Generate(ServiceClient serviceClient) { var extensionsTemplate = new ExtensionsTemplate { - Model = new AzureExtensionsTemplateModel(serviceClient, null, SyncWrappers), + Model = new AzureExtensionsTemplateModel(serviceClient, null, SyncMethods), }; await Write(extensionsTemplate, serviceClient.Name + "Extensions.cs"); } @@ -124,7 +124,7 @@ public override async Task Generate(ServiceClient serviceClient) // Service client extensions var operationExtensionsTemplate = new ExtensionsTemplate { - Model = new AzureExtensionsTemplateModel(serviceClient, group, SyncWrappers), + Model = new AzureExtensionsTemplateModel(serviceClient, group, SyncMethods), }; await Write(operationExtensionsTemplate, operationExtensionsTemplate.Model.ExtensionName + "Extensions.cs"); diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs index 8dcb1228f5da..75bb66b25e20 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureExtensionsTemplateModel.cs @@ -12,7 +12,7 @@ namespace Microsoft.Rest.Generator.CSharp.Azure { public class AzureExtensionsTemplateModel : ExtensionsTemplateModel { - public AzureExtensionsTemplateModel(ServiceClient serviceClient, string operationName, SyncWrapperGenerationMode syncWrappers) + public AzureExtensionsTemplateModel(ServiceClient serviceClient, string operationName, SyncMethodsGenerationMode syncWrappers) : base(serviceClient, operationName, syncWrappers) { MethodTemplateModels.Clear(); diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs index ecadbc1708f8..adc17c0dfa26 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodGroupTemplateModel.cs @@ -20,7 +20,7 @@ public AzureMethodGroupTemplateModel(ServiceClient serviceClient, string methodG // AzureMethodTemplateModel MethodTemplateModels.Clear(); Methods.Where(m => m.Group == methodGroupName) - .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); + .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, SyncMethodsGenerationMode.None))); } /// diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs index e393a7d502ed..4fdb8272d79a 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureMethodTemplateModel.cs @@ -15,7 +15,7 @@ namespace Microsoft.Rest.Generator.CSharp.Azure { public class AzureMethodTemplateModel : MethodTemplateModel { - public AzureMethodTemplateModel(Method source, ServiceClient serviceClient, SyncWrapperGenerationMode syncWrappers) + public AzureMethodTemplateModel(Method source, ServiceClient serviceClient, SyncMethodsGenerationMode syncWrappers) : base(source, serviceClient, syncWrappers) { if (source == null) @@ -54,7 +54,7 @@ public AzureMethodTemplateModel GetMethod Resources.InvalidLongRunningOperationForCreateOrUpdate, Name, Group)); } - return new AzureMethodTemplateModel(getMethod, ServiceClient, SyncWrappers); + return new AzureMethodTemplateModel(getMethod, ServiceClient, SyncMethods); } } diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs index a790ba0367f6..f48e88336a35 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/TemplateModels/AzureServiceClientTemplateModel.cs @@ -18,7 +18,7 @@ public AzureServiceClientTemplateModel(ServiceClient serviceClient, bool interna // TODO: Initialized in the base constructor. Why Clear it? MethodTemplateModels.Clear(); Methods.Where(m => m.Group == null) - .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); + .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, SyncMethodsGenerationMode.None))); } /// diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs b/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs index a2d0b461e740..06eb37287fa8 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs @@ -2262,6 +2262,22 @@ public void ModelFlatteningWithGroupingTest() } } + [Fact] + public void SyncMethodsValidation() + { + Type petstoreWithAllSyncMethods = typeof(Fixtures.PetstoreV2AllSync.SwaggerPetstoreV2Extensions); + Assert.NotNull(petstoreWithAllSyncMethods.GetMethod("AddPet")); + Assert.NotNull(petstoreWithAllSyncMethods.GetMethod("AddPetWithHttpMessages")); + + Type petstoreWithNoSyncMethods = typeof(Fixtures.PetstoreV2NoSync.SwaggerPetstoreV2Extensions); + Assert.Null(petstoreWithNoSyncMethods.GetMethod("AddPet")); + Assert.Null(petstoreWithNoSyncMethods.GetMethod("AddPetWithHttpMessages")); + + Type petstoreWithEssentialSyncMethods = typeof(Fixtures.PetstoreV2.SwaggerPetstoreV2Extensions); + Assert.NotNull(petstoreWithEssentialSyncMethods.GetMethod("AddPet")); + Assert.Null(petstoreWithEssentialSyncMethods.GetMethod("AddPetWithHttpMessages")); + } + public void EnsureTestCoverage() { SwaggerSpecRunner.RunTests( diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs new file mode 100644 index 000000000000..05eddda353c7 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Newtonsoft.Json; + using Microsoft.Rest; + using Models; + + /// + /// This is a sample server Petstore server. You can find out more about + /// Swagger at <a + /// href="http://swagger.io">http://swagger.io</a> or on + /// irc.freenode.net, #swagger. For this sample, you can use the api key + /// "special-key" to test the authorization filters + /// + public partial interface ISwaggerPetstoreV2 : IDisposable + { + /// + /// The base URI of the service. + /// + Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + + /// + /// Add a new pet to the store + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> AddPetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Update an existing pet + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task UpdatePetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> FindPetsByStatusWithHttpMessagesAsync(IList status, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use + /// tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// Id of pet to return + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Updates a pet in the store with form data + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task UpdatePetWithFormWithHttpMessagesAsync(long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Deletes a pet + /// + /// + /// Pet id to delete + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = "", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Place an order for a pet + /// + /// + /// order placed for purchasing the pet + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> PlaceOrderWithHttpMessagesAsync(Order body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. + /// Other values will generated exceptions + /// + /// Id of pet that needs to be fetched + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything + /// above 1000 or nonintegers will generate API errors + /// + /// Id of the order that needs to be deleted + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task CreateUserWithHttpMessagesAsync(User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task CreateUsersWithListInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Logs user into the system + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> LoginUserWithHttpMessagesAsync(string username, string password, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Logs out current logged in user session + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Get user by user name + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task UpdateUserWithHttpMessagesAsync(string username, User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs new file mode 100644 index 000000000000..3db78b2246df --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class ApiResponse + { + /// + /// Initializes a new instance of the ApiResponse class. + /// + public ApiResponse() { } + + /// + /// Initializes a new instance of the ApiResponse class. + /// + public ApiResponse(int? code = default(int?), string type = default(string), string message = default(string)) + { + Code = code; + Type = type; + Message = message; + } + + /// + /// + [JsonProperty(PropertyName = "code")] + public int? Code { get; set; } + + /// + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs new file mode 100644 index 000000000000..afce154a08f2 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Category + { + /// + /// Initializes a new instance of the Category class. + /// + public Category() { } + + /// + /// Initializes a new instance of the Category class. + /// + public Category(long? id = default(long?), string name = default(string)) + { + Id = id; + Name = name; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs new file mode 100644 index 000000000000..adb1cbec27fd --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + /// + /// Defines headers for loginUser operation. + /// + public partial class LoginUserHeaders + { + /// + /// Initializes a new instance of the LoginUserHeaders class. + /// + public LoginUserHeaders() { } + + /// + /// Initializes a new instance of the LoginUserHeaders class. + /// + public LoginUserHeaders(int? xRateLimit = default(int?), DateTime? xExpiresAfter = default(DateTime?)) + { + XRateLimit = xRateLimit; + XExpiresAfter = xExpiresAfter; + } + + /// + /// Gets or sets calls per hour allowed by the user + /// + [JsonProperty(PropertyName = "X-Rate-Limit")] + public int? XRateLimit { get; set; } + + /// + /// Gets or sets date in UTC when toekn expires + /// + [JsonProperty(PropertyName = "X-Expires-After")] + public DateTime? XExpiresAfter { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs new file mode 100644 index 000000000000..301590aa5c81 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Order + { + /// + /// Initializes a new instance of the Order class. + /// + public Order() { } + + /// + /// Initializes a new instance of the Order class. + /// + public Order(long? id = default(long?), long? petId = default(long?), int? quantity = default(int?), DateTime? shipDate = default(DateTime?), string status = default(string), bool? complete = default(bool?)) + { + Id = id; + PetId = petId; + Quantity = quantity; + ShipDate = shipDate; + Status = status; + Complete = complete; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "petId")] + public long? PetId { get; set; } + + /// + /// + [JsonProperty(PropertyName = "quantity")] + public int? Quantity { get; set; } + + /// + /// + [JsonProperty(PropertyName = "shipDate")] + public DateTime? ShipDate { get; set; } + + /// + /// Gets or sets order Status. Possible values include: 'placed', + /// 'approved', 'delivered' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// + [JsonProperty(PropertyName = "complete")] + public bool? Complete { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs new file mode 100644 index 000000000000..006deb06f472 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Pet + { + /// + /// Initializes a new instance of the Pet class. + /// + public Pet() { } + + /// + /// Initializes a new instance of the Pet class. + /// + public Pet(string name, IList photoUrls, long? id = default(long?), Category category = default(Category), IList tags = default(IList), byte[] sByteProperty = default(byte[]), DateTime? birthday = default(DateTime?), IDictionary dictionary = default(IDictionary), string status = default(string)) + { + Id = id; + Category = category; + Name = name; + PhotoUrls = photoUrls; + Tags = tags; + SByteProperty = sByteProperty; + Birthday = birthday; + Dictionary = dictionary; + Status = status; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "category")] + public Category Category { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "photoUrls")] + public IList PhotoUrls { get; set; } + + /// + /// + [JsonProperty(PropertyName = "tags")] + public IList Tags { get; set; } + + /// + /// + [JsonProperty(PropertyName = "sByte")] + public byte[] SByteProperty { get; set; } + + /// + /// + [JsonProperty(PropertyName = "birthday")] + public DateTime? Birthday { get; set; } + + /// + /// + [JsonProperty(PropertyName = "dictionary")] + public IDictionary Dictionary { get; set; } + + /// + /// Gets or sets pet status in the store. Possible values include: + /// 'available', 'pending', 'sold' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Validate the object. Throws ValidationException if validation fails. + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (PhotoUrls == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls"); + } + } + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs new file mode 100644 index 000000000000..d9e9a413c300 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Tag + { + /// + /// Initializes a new instance of the Tag class. + /// + public Tag() { } + + /// + /// Initializes a new instance of the Tag class. + /// + public Tag(long? id = default(long?), string name = default(string)) + { + Id = id; + Name = name; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs new file mode 100644 index 000000000000..215ab2c2f6ca --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class User + { + /// + /// Initializes a new instance of the User class. + /// + public User() { } + + /// + /// Initializes a new instance of the User class. + /// + 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; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + /// + /// + [JsonProperty(PropertyName = "firstName")] + public string FirstName { get; set; } + + /// + /// + [JsonProperty(PropertyName = "lastName")] + public string LastName { get; set; } + + /// + /// + [JsonProperty(PropertyName = "email")] + public string Email { get; set; } + + /// + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + /// + /// + [JsonProperty(PropertyName = "phone")] + public string Phone { get; set; } + + /// + /// Gets or sets user Status + /// + [JsonProperty(PropertyName = "userStatus")] + public int? UserStatus { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs new file mode 100644 index 000000000000..2d744c04bc7f --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs @@ -0,0 +1,2331 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Diagnostics; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using Models; + + /// + /// This is a sample server Petstore server. You can find out more about + /// Swagger at <a + /// href="http://swagger.io">http://swagger.io</a> or on + /// irc.freenode.net, #swagger. For this sample, you can use the api key + /// "special-key" to test the authorization filters + /// + public partial class SwaggerPetstoreV2 : ServiceClient, ISwaggerPetstoreV2 + { + /// + /// The base URI of the service. + /// + public Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(params DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.BaseUri = new Uri("http://petstore.swagger.io/v2"); + SerializationSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + } + /// + /// Add a new pet to the store + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> AddPetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "AddPet", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 405 && (int)_statusCode != 200) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update an existing pet + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task UpdatePetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdatePet", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404 && (int)_statusCode != 405) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> FindPetsByStatusWithHttpMessagesAsync(IList status, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (status == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "status"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("status", status); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "FindPetsByStatus", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByStatus").ToString(); + List _queryParameters = new List(); + if (status != null) + { + _queryParameters.Add(string.Format("status={0}", Uri.EscapeDataString(string.Join(",", status)))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, + /// tag3 for testing. + /// + /// Tags to filter by + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (tags == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tags"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tags", tags); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "FindPetsByTags", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByTags").ToString(); + List _queryParameters = new List(); + if (tags != null) + { + _queryParameters.Add(string.Format("tags={0}", Uri.EscapeDataString(string.Join(",", tags)))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// Id of pet to return + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("petId", petId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPetById", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); + _url = _url.Replace("{petId}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, this.SerializationSettings).Trim('"'))); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a pet in the store with form data + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task UpdatePetWithFormWithHttpMessagesAsync(long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (fileContent == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "fileContent"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("petId", petId); + tracingParameters.Add("fileContent", fileContent); + tracingParameters.Add("fileName", fileName); + tracingParameters.Add("status", status); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdatePetWithForm", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); + _url = _url.Replace("{petId}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, this.SerializationSettings).Trim('"'))); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + MultipartFormDataContent _multiPartContent = new MultipartFormDataContent(); + if (fileContent != null) + { + StreamContent _fileContent = new StreamContent(fileContent); + _fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); + System.IO.FileStream _fileContentAsFileStream = fileContent as System.IO.FileStream; + if (_fileContentAsFileStream != null) + { + ContentDispositionHeaderValue _contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-data"); + _contentDispositionHeaderValue.Name = "fileContent"; + _contentDispositionHeaderValue.FileName = _fileContentAsFileStream.Name; + _fileContent.Headers.ContentDisposition = _contentDispositionHeaderValue; + } + _multiPartContent.Add(_fileContent, "fileContent"); + } + if (fileName != null) + { + StringContent _fileName = new StringContent(fileName, Encoding.UTF8); + _multiPartContent.Add(_fileName, "fileName"); + } + if (status != null) + { + StringContent _status = new StringContent(status, Encoding.UTF8); + _multiPartContent.Add(_status, "status"); + } + _httpRequest.Content = _multiPartContent; + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 405) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a pet + /// + /// + /// Pet id to delete + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = "", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiKey", apiKey); + tracingParameters.Add("petId", petId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeletePet", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); + _url = _url.Replace("{petId}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, this.SerializationSettings).Trim('"'))); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (apiKey != null) + { + if (_httpRequest.Headers.Contains("api_key")) + { + _httpRequest.Headers.Remove("api_key"); + } + _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetInventory", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/inventory").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.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)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Place an order for a pet + /// + /// + /// order placed for purchasing the pet + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> PlaceOrderWithHttpMessagesAsync(Order body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "PlaceOrder", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other + /// values will generated exceptions + /// + /// Id of pet that needs to be fetched + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (orderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); + } + if (orderId != null) + { + if (orderId.Length > 5) + { + throw new ValidationException(ValidationRules.MaxLength, "orderId", 5); + } + if (orderId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "orderId", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("orderId", orderId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetOrderById", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); + _url = _url.Replace("{orderId}", Uri.EscapeDataString(orderId)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything above + /// 1000 or nonintegers will generate API errors + /// + /// Id of the order that needs to be deleted + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (orderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); + } + if (orderId != null) + { + if (orderId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "orderId", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("orderId", orderId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteOrder", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); + _url = _url.Replace("{orderId}", Uri.EscapeDataString(orderId)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CreateUserWithHttpMessagesAsync(User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithArrayInput", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithArray").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CreateUsersWithListInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithListInput", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithList").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Logs user into the system + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> LoginUserWithHttpMessagesAsync(string username, string password, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + if (password == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "password"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("password", password); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "LoginUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/login").ToString(); + List _queryParameters = new List(); + if (username != null) + { + _queryParameters.Add(string.Format("username={0}", Uri.EscapeDataString(username))); + } + if (password != null) + { + _queryParameters.Add(string.Format("password={0}", Uri.EscapeDataString(password))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(this.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; + } + + /// + /// Logs out current logged in user session + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "LogoutUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/logout").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get user by user name + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetUserByName", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); + _url = _url.Replace("{username}", Uri.EscapeDataString(username)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task UpdateUserWithHttpMessagesAsync(string username, User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); + _url = _url.Replace("{username}", Uri.EscapeDataString(username)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); + _url = _url.Replace("{username}", Uri.EscapeDataString(username)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + 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; + } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2Extensions.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2Extensions.cs new file mode 100644 index 000000000000..7632b1ccaf3f --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2Extensions.cs @@ -0,0 +1,1033 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2AllSync +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Models; + + /// + /// Extension methods for SwaggerPetstoreV2. + /// + public static partial class SwaggerPetstoreV2Extensions + { + /// + /// Add a new pet to the store + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + public static Pet AddPet(this ISwaggerPetstoreV2 operations, Pet body) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).AddPetAsync(body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Add a new pet to the store + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The cancellation token. + /// + public static async Task AddPetAsync(this ISwaggerPetstoreV2 operations, Pet body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.AddPetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Add a new pet to the store + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse AddPetWithHttpMessages(this ISwaggerPetstoreV2 operations, Pet body, Dictionary> customHeaders = null) + { + return operations.AddPetWithHttpMessagesAsync(body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Update an existing pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + public static void UpdatePet(this ISwaggerPetstoreV2 operations, Pet body) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).UpdatePetAsync(body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Update an existing pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The cancellation token. + /// + public static async Task UpdatePetAsync(this ISwaggerPetstoreV2 operations, Pet body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.UpdatePetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update an existing pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse UpdatePetWithHttpMessages(this ISwaggerPetstoreV2 operations, Pet body, Dictionary> customHeaders = null) + { + return operations.UpdatePetWithHttpMessagesAsync(body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// The operations group for this extension method. + /// + /// + /// Status values that need to be considered for filter + /// + public static IList FindPetsByStatus(this ISwaggerPetstoreV2 operations, IList status) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).FindPetsByStatusAsync(status), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// The operations group for this extension method. + /// + /// + /// Status values that need to be considered for filter + /// + /// + /// The cancellation token. + /// + public static async Task> FindPetsByStatusAsync(this ISwaggerPetstoreV2 operations, IList status, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.FindPetsByStatusWithHttpMessagesAsync(status, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// The operations group for this extension method. + /// + /// + /// Status values that need to be considered for filter + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse> FindPetsByStatusWithHttpMessages(this ISwaggerPetstoreV2 operations, IList status, Dictionary> customHeaders = null) + { + return operations.FindPetsByStatusWithHttpMessagesAsync(status, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, + /// tag3 for testing. + /// + /// The operations group for this extension method. + /// + /// + /// Tags to filter by + /// + public static IList FindPetsByTags(this ISwaggerPetstoreV2 operations, IList tags) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).FindPetsByTagsAsync(tags), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, + /// tag3 for testing. + /// + /// The operations group for this extension method. + /// + /// + /// Tags to filter by + /// + /// + /// The cancellation token. + /// + public static async Task> FindPetsByTagsAsync(this ISwaggerPetstoreV2 operations, IList tags, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.FindPetsByTagsWithHttpMessagesAsync(tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, + /// tag3 for testing. + /// + /// The operations group for this extension method. + /// + /// + /// Tags to filter by + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse> FindPetsByTagsWithHttpMessages(this ISwaggerPetstoreV2 operations, IList tags, Dictionary> customHeaders = null) + { + return operations.FindPetsByTagsWithHttpMessagesAsync(tags, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet to return + /// + public static Pet GetPetById(this ISwaggerPetstoreV2 operations, long petId) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).GetPetByIdAsync(petId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet to return + /// + /// + /// The cancellation token. + /// + public static async Task GetPetByIdAsync(this ISwaggerPetstoreV2 operations, long petId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet to return + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse GetPetByIdWithHttpMessages(this ISwaggerPetstoreV2 operations, long petId, Dictionary> customHeaders = null) + { + return operations.GetPetByIdWithHttpMessagesAsync(petId, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Updates a pet in the store with form data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + public static void UpdatePetWithForm(this ISwaggerPetstoreV2 operations, long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string)) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).UpdatePetWithFormAsync(petId, fileContent, fileName, status), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Updates a pet in the store with form data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + /// + /// The cancellation token. + /// + public static async Task UpdatePetWithFormAsync(this ISwaggerPetstoreV2 operations, long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.UpdatePetWithFormWithHttpMessagesAsync(petId, fileContent, fileName, status, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a pet in the store with form data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse UpdatePetWithFormWithHttpMessages(this ISwaggerPetstoreV2 operations, long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string), Dictionary> customHeaders = null) + { + return operations.UpdatePetWithFormWithHttpMessagesAsync(petId, fileContent, fileName, status, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Deletes a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet id to delete + /// + /// + /// + public static void DeletePet(this ISwaggerPetstoreV2 operations, long petId, string apiKey = "") + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).DeletePetAsync(petId, apiKey), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Deletes a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet id to delete + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task DeletePetAsync(this ISwaggerPetstoreV2 operations, long petId, string apiKey = "", CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.DeletePetWithHttpMessagesAsync(petId, apiKey, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet id to delete + /// + /// + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse DeletePetWithHttpMessages(this ISwaggerPetstoreV2 operations, long petId, string apiKey = "", Dictionary> customHeaders = null) + { + return operations.DeletePetWithHttpMessagesAsync(petId, apiKey, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// The operations group for this extension method. + /// + public static IDictionary GetInventory(this ISwaggerPetstoreV2 operations) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).GetInventoryAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> GetInventoryAsync(this ISwaggerPetstoreV2 operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetInventoryWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// The operations group for this extension method. + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse> GetInventoryWithHttpMessages(this ISwaggerPetstoreV2 operations, Dictionary> customHeaders = null) + { + return operations.GetInventoryWithHttpMessagesAsync(customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Place an order for a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// order placed for purchasing the pet + /// + public static Order PlaceOrder(this ISwaggerPetstoreV2 operations, Order body) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).PlaceOrderAsync(body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Place an order for a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// order placed for purchasing the pet + /// + /// + /// The cancellation token. + /// + public static async Task PlaceOrderAsync(this ISwaggerPetstoreV2 operations, Order body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PlaceOrderWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Place an order for a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// order placed for purchasing the pet + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse PlaceOrderWithHttpMessages(this ISwaggerPetstoreV2 operations, Order body, Dictionary> customHeaders = null) + { + return operations.PlaceOrderWithHttpMessagesAsync(body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other + /// values will generated exceptions + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be fetched + /// + public static Order GetOrderById(this ISwaggerPetstoreV2 operations, string orderId) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).GetOrderByIdAsync(orderId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other + /// values will generated exceptions + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be fetched + /// + /// + /// The cancellation token. + /// + public static async Task GetOrderByIdAsync(this ISwaggerPetstoreV2 operations, string orderId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOrderByIdWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other + /// values will generated exceptions + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be fetched + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse GetOrderByIdWithHttpMessages(this ISwaggerPetstoreV2 operations, string orderId, Dictionary> customHeaders = null) + { + return operations.GetOrderByIdWithHttpMessagesAsync(orderId, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything above + /// 1000 or nonintegers will generate API errors + /// + /// The operations group for this extension method. + /// + /// + /// Id of the order that needs to be deleted + /// + public static void DeleteOrder(this ISwaggerPetstoreV2 operations, string orderId) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).DeleteOrderAsync(orderId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything above + /// 1000 or nonintegers will generate API errors + /// + /// The operations group for this extension method. + /// + /// + /// Id of the order that needs to be deleted + /// + /// + /// The cancellation token. + /// + public static async Task DeleteOrderAsync(this ISwaggerPetstoreV2 operations, string orderId, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.DeleteOrderWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything above + /// 1000 or nonintegers will generate API errors + /// + /// The operations group for this extension method. + /// + /// + /// Id of the order that needs to be deleted + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse DeleteOrderWithHttpMessages(this ISwaggerPetstoreV2 operations, string orderId, Dictionary> customHeaders = null) + { + return operations.DeleteOrderWithHttpMessagesAsync(orderId, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// Created user object + /// + public static void CreateUser(this ISwaggerPetstoreV2 operations, User body) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).CreateUserAsync(body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// Created user object + /// + /// + /// The cancellation token. + /// + public static async Task CreateUserAsync(this ISwaggerPetstoreV2 operations, User body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.CreateUserWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// Created user object + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse CreateUserWithHttpMessages(this ISwaggerPetstoreV2 operations, User body, Dictionary> customHeaders = null) + { + return operations.CreateUserWithHttpMessagesAsync(body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + public static void CreateUsersWithArrayInput(this ISwaggerPetstoreV2 operations, IList body) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).CreateUsersWithArrayInputAsync(body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + /// + /// The cancellation token. + /// + public static async Task CreateUsersWithArrayInputAsync(this ISwaggerPetstoreV2 operations, IList body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.CreateUsersWithArrayInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse CreateUsersWithArrayInputWithHttpMessages(this ISwaggerPetstoreV2 operations, IList body, Dictionary> customHeaders = null) + { + return operations.CreateUsersWithArrayInputWithHttpMessagesAsync(body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + public static void CreateUsersWithListInput(this ISwaggerPetstoreV2 operations, IList body) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).CreateUsersWithListInputAsync(body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + /// + /// The cancellation token. + /// + public static async Task CreateUsersWithListInputAsync(this ISwaggerPetstoreV2 operations, IList body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.CreateUsersWithListInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse CreateUsersWithListInputWithHttpMessages(this ISwaggerPetstoreV2 operations, IList body, Dictionary> customHeaders = null) + { + return operations.CreateUsersWithListInputWithHttpMessagesAsync(body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Logs user into the system + /// + /// + /// The operations group for this extension method. + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + public static string LoginUser(this ISwaggerPetstoreV2 operations, string username, string password) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).LoginUserAsync(username, password), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Logs user into the system + /// + /// + /// The operations group for this extension method. + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + /// + /// The cancellation token. + /// + public static async Task LoginUserAsync(this ISwaggerPetstoreV2 operations, string username, string password, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.LoginUserWithHttpMessagesAsync(username, password, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Logs user into the system + /// + /// + /// The operations group for this extension method. + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse LoginUserWithHttpMessages(this ISwaggerPetstoreV2 operations, string username, string password, Dictionary> customHeaders = null) + { + return operations.LoginUserWithHttpMessagesAsync(username, password, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Logs out current logged in user session + /// + /// + /// The operations group for this extension method. + /// + public static void LogoutUser(this ISwaggerPetstoreV2 operations) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).LogoutUserAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Logs out current logged in user session + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task LogoutUserAsync(this ISwaggerPetstoreV2 operations, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.LogoutUserWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Logs out current logged in user session + /// + /// + /// The operations group for this extension method. + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse LogoutUserWithHttpMessages(this ISwaggerPetstoreV2 operations, Dictionary> customHeaders = null) + { + return operations.LogoutUserWithHttpMessagesAsync(customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Get user by user name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + public static User GetUserByName(this ISwaggerPetstoreV2 operations, string username) + { + return Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).GetUserByNameAsync(username), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get user by user name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + /// + /// The cancellation token. + /// + public static async Task GetUserByNameAsync(this ISwaggerPetstoreV2 operations, string username, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetUserByNameWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get user by user name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse GetUserByNameWithHttpMessages(this ISwaggerPetstoreV2 operations, string username, Dictionary> customHeaders = null) + { + return operations.GetUserByNameWithHttpMessagesAsync(username, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + public static void UpdateUser(this ISwaggerPetstoreV2 operations, string username, User body) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).UpdateUserAsync(username, body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + /// + /// The cancellation token. + /// + public static async Task UpdateUserAsync(this ISwaggerPetstoreV2 operations, string username, User body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.UpdateUserWithHttpMessagesAsync(username, body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse UpdateUserWithHttpMessages(this ISwaggerPetstoreV2 operations, string username, User body, Dictionary> customHeaders = null) + { + return operations.UpdateUserWithHttpMessagesAsync(username, body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be deleted + /// + public static void DeleteUser(this ISwaggerPetstoreV2 operations, string username) + { + Task.Factory.StartNew(s => ((ISwaggerPetstoreV2)s).DeleteUserAsync(username), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be deleted + /// + /// + /// The cancellation token. + /// + public static async Task DeleteUserAsync(this ISwaggerPetstoreV2 operations, string username, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.DeleteUserWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be deleted + /// + /// + /// Headers that will be added to request. + /// + public static HttpOperationResponse DeleteUserWithHttpMessages(this ISwaggerPetstoreV2 operations, string username, Dictionary> customHeaders = null) + { + return operations.DeleteUserWithHttpMessagesAsync(username, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); + } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs new file mode 100644 index 000000000000..2e7c79b71f92 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Newtonsoft.Json; + using Microsoft.Rest; + using Models; + + /// + /// This is a sample server Petstore server. You can find out more about + /// Swagger at <a + /// href="http://swagger.io">http://swagger.io</a> or on + /// irc.freenode.net, #swagger. For this sample, you can use the api key + /// "special-key" to test the authorization filters + /// + public partial interface ISwaggerPetstoreV2 : IDisposable + { + /// + /// The base URI of the service. + /// + Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + + /// + /// Add a new pet to the store + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> AddPetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Update an existing pet + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task UpdatePetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> FindPetsByStatusWithHttpMessagesAsync(IList status, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use + /// tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// Id of pet to return + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Updates a pet in the store with form data + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task UpdatePetWithFormWithHttpMessagesAsync(long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Deletes a pet + /// + /// + /// Pet id to delete + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = "", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Place an order for a pet + /// + /// + /// order placed for purchasing the pet + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> PlaceOrderWithHttpMessagesAsync(Order body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. + /// Other values will generated exceptions + /// + /// Id of pet that needs to be fetched + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything + /// above 1000 or nonintegers will generate API errors + /// + /// Id of the order that needs to be deleted + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task CreateUserWithHttpMessagesAsync(User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task CreateUsersWithListInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Logs user into the system + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> LoginUserWithHttpMessagesAsync(string username, string password, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Logs out current logged in user session + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Get user by user name + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task UpdateUserWithHttpMessagesAsync(string username, User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs new file mode 100644 index 000000000000..94f2d00e0825 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class ApiResponse + { + /// + /// Initializes a new instance of the ApiResponse class. + /// + public ApiResponse() { } + + /// + /// Initializes a new instance of the ApiResponse class. + /// + public ApiResponse(int? code = default(int?), string type = default(string), string message = default(string)) + { + Code = code; + Type = type; + Message = message; + } + + /// + /// + [JsonProperty(PropertyName = "code")] + public int? Code { get; set; } + + /// + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs new file mode 100644 index 000000000000..f284e6abd4db --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Category + { + /// + /// Initializes a new instance of the Category class. + /// + public Category() { } + + /// + /// Initializes a new instance of the Category class. + /// + public Category(long? id = default(long?), string name = default(string)) + { + Id = id; + Name = name; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs new file mode 100644 index 000000000000..f39e029d64a6 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + /// + /// Defines headers for loginUser operation. + /// + public partial class LoginUserHeaders + { + /// + /// Initializes a new instance of the LoginUserHeaders class. + /// + public LoginUserHeaders() { } + + /// + /// Initializes a new instance of the LoginUserHeaders class. + /// + public LoginUserHeaders(int? xRateLimit = default(int?), DateTime? xExpiresAfter = default(DateTime?)) + { + XRateLimit = xRateLimit; + XExpiresAfter = xExpiresAfter; + } + + /// + /// Gets or sets calls per hour allowed by the user + /// + [JsonProperty(PropertyName = "X-Rate-Limit")] + public int? XRateLimit { get; set; } + + /// + /// Gets or sets date in UTC when toekn expires + /// + [JsonProperty(PropertyName = "X-Expires-After")] + public DateTime? XExpiresAfter { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs new file mode 100644 index 000000000000..417f442a6465 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Order + { + /// + /// Initializes a new instance of the Order class. + /// + public Order() { } + + /// + /// Initializes a new instance of the Order class. + /// + public Order(long? id = default(long?), long? petId = default(long?), int? quantity = default(int?), DateTime? shipDate = default(DateTime?), string status = default(string), bool? complete = default(bool?)) + { + Id = id; + PetId = petId; + Quantity = quantity; + ShipDate = shipDate; + Status = status; + Complete = complete; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "petId")] + public long? PetId { get; set; } + + /// + /// + [JsonProperty(PropertyName = "quantity")] + public int? Quantity { get; set; } + + /// + /// + [JsonProperty(PropertyName = "shipDate")] + public DateTime? ShipDate { get; set; } + + /// + /// Gets or sets order Status. Possible values include: 'placed', + /// 'approved', 'delivered' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// + [JsonProperty(PropertyName = "complete")] + public bool? Complete { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs new file mode 100644 index 000000000000..b49d6ed7eddc --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Pet + { + /// + /// Initializes a new instance of the Pet class. + /// + public Pet() { } + + /// + /// Initializes a new instance of the Pet class. + /// + public Pet(string name, IList photoUrls, long? id = default(long?), Category category = default(Category), IList tags = default(IList), byte[] sByteProperty = default(byte[]), DateTime? birthday = default(DateTime?), IDictionary dictionary = default(IDictionary), string status = default(string)) + { + Id = id; + Category = category; + Name = name; + PhotoUrls = photoUrls; + Tags = tags; + SByteProperty = sByteProperty; + Birthday = birthday; + Dictionary = dictionary; + Status = status; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "category")] + public Category Category { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "photoUrls")] + public IList PhotoUrls { get; set; } + + /// + /// + [JsonProperty(PropertyName = "tags")] + public IList Tags { get; set; } + + /// + /// + [JsonProperty(PropertyName = "sByte")] + public byte[] SByteProperty { get; set; } + + /// + /// + [JsonProperty(PropertyName = "birthday")] + public DateTime? Birthday { get; set; } + + /// + /// + [JsonProperty(PropertyName = "dictionary")] + public IDictionary Dictionary { get; set; } + + /// + /// Gets or sets pet status in the store. Possible values include: + /// 'available', 'pending', 'sold' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Validate the object. Throws ValidationException if validation fails. + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (PhotoUrls == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls"); + } + } + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs new file mode 100644 index 000000000000..1d662dfcb83d --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Tag + { + /// + /// Initializes a new instance of the Tag class. + /// + public Tag() { } + + /// + /// Initializes a new instance of the Tag class. + /// + public Tag(long? id = default(long?), string name = default(string)) + { + Id = id; + Name = name; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs new file mode 100644 index 000000000000..293823aaf39d --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class User + { + /// + /// Initializes a new instance of the User class. + /// + public User() { } + + /// + /// Initializes a new instance of the User class. + /// + 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; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public long? Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + /// + /// + [JsonProperty(PropertyName = "firstName")] + public string FirstName { get; set; } + + /// + /// + [JsonProperty(PropertyName = "lastName")] + public string LastName { get; set; } + + /// + /// + [JsonProperty(PropertyName = "email")] + public string Email { get; set; } + + /// + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + /// + /// + [JsonProperty(PropertyName = "phone")] + public string Phone { get; set; } + + /// + /// Gets or sets user Status + /// + [JsonProperty(PropertyName = "userStatus")] + public int? UserStatus { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs new file mode 100644 index 000000000000..4a0b55bf23e4 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs @@ -0,0 +1,2331 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Diagnostics; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using Models; + + /// + /// This is a sample server Petstore server. You can find out more about + /// Swagger at <a + /// href="http://swagger.io">http://swagger.io</a> or on + /// irc.freenode.net, #swagger. For this sample, you can use the api key + /// "special-key" to test the authorization filters + /// + public partial class SwaggerPetstoreV2 : ServiceClient, ISwaggerPetstoreV2 + { + /// + /// The base URI of the service. + /// + public Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(params DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the SwaggerPetstoreV2 class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public SwaggerPetstoreV2(Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.BaseUri = new Uri("http://petstore.swagger.io/v2"); + SerializationSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + } + /// + /// Add a new pet to the store + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> AddPetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "AddPet", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 405 && (int)_statusCode != 200) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update an existing pet + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task UpdatePetWithHttpMessagesAsync(Pet body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdatePet", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404 && (int)_statusCode != 405) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> FindPetsByStatusWithHttpMessagesAsync(IList status, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (status == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "status"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("status", status); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "FindPetsByStatus", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByStatus").ToString(); + List _queryParameters = new List(); + if (status != null) + { + _queryParameters.Add(string.Format("status={0}", Uri.EscapeDataString(string.Join(",", status)))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, + /// tag3 for testing. + /// + /// Tags to filter by + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (tags == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tags"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tags", tags); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "FindPetsByTags", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByTags").ToString(); + List _queryParameters = new List(); + if (tags != null) + { + _queryParameters.Add(string.Format("tags={0}", Uri.EscapeDataString(string.Join(",", tags)))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// Id of pet to return + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("petId", petId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPetById", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); + _url = _url.Replace("{petId}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, this.SerializationSettings).Trim('"'))); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a pet in the store with form data + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task UpdatePetWithFormWithHttpMessagesAsync(long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (fileContent == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "fileContent"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("petId", petId); + tracingParameters.Add("fileContent", fileContent); + tracingParameters.Add("fileName", fileName); + tracingParameters.Add("status", status); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdatePetWithForm", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); + _url = _url.Replace("{petId}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, this.SerializationSettings).Trim('"'))); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + MultipartFormDataContent _multiPartContent = new MultipartFormDataContent(); + if (fileContent != null) + { + StreamContent _fileContent = new StreamContent(fileContent); + _fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); + System.IO.FileStream _fileContentAsFileStream = fileContent as System.IO.FileStream; + if (_fileContentAsFileStream != null) + { + ContentDispositionHeaderValue _contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-data"); + _contentDispositionHeaderValue.Name = "fileContent"; + _contentDispositionHeaderValue.FileName = _fileContentAsFileStream.Name; + _fileContent.Headers.ContentDisposition = _contentDispositionHeaderValue; + } + _multiPartContent.Add(_fileContent, "fileContent"); + } + if (fileName != null) + { + StringContent _fileName = new StringContent(fileName, Encoding.UTF8); + _multiPartContent.Add(_fileName, "fileName"); + } + if (status != null) + { + StringContent _status = new StringContent(status, Encoding.UTF8); + _multiPartContent.Add(_status, "status"); + } + _httpRequest.Content = _multiPartContent; + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 405) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a pet + /// + /// + /// Pet id to delete + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = "", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiKey", apiKey); + tracingParameters.Add("petId", petId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeletePet", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString(); + _url = _url.Replace("{petId}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, this.SerializationSettings).Trim('"'))); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (apiKey != null) + { + if (_httpRequest.Headers.Contains("api_key")) + { + _httpRequest.Headers.Remove("api_key"); + } + _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey); + } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetInventory", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/inventory").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.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)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Place an order for a pet + /// + /// + /// order placed for purchasing the pet + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> PlaceOrderWithHttpMessagesAsync(Order body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "PlaceOrder", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other + /// values will generated exceptions + /// + /// Id of pet that needs to be fetched + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (orderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); + } + if (orderId != null) + { + if (orderId.Length > 5) + { + throw new ValidationException(ValidationRules.MaxLength, "orderId", 5); + } + if (orderId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "orderId", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("orderId", orderId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetOrderById", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); + _url = _url.Replace("{orderId}", Uri.EscapeDataString(orderId)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything above + /// 1000 or nonintegers will generate API errors + /// + /// Id of the order that needs to be deleted + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (orderId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "orderId"); + } + if (orderId != null) + { + if (orderId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "orderId", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("orderId", orderId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteOrder", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString(); + _url = _url.Replace("{orderId}", Uri.EscapeDataString(orderId)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CreateUserWithHttpMessagesAsync(User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithArrayInput", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithArray").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CreateUsersWithListInputWithHttpMessagesAsync(IList body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithListInput", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithList").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Logs user into the system + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> LoginUserWithHttpMessagesAsync(string username, string password, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + if (password == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "password"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("password", password); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "LoginUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/login").ToString(); + List _queryParameters = new List(); + if (username != null) + { + _queryParameters.Add(string.Format("username={0}", Uri.EscapeDataString(username))); + } + if (password != null) + { + _queryParameters.Add(string.Format("password={0}", Uri.EscapeDataString(password))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(this.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; + } + + /// + /// Logs out current logged in user session + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "LogoutUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/logout").ToString(); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if (!_httpResponse.IsSuccessStatusCode) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get user by user name + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetUserByName", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); + _url = _url.Replace("{username}", Uri.EscapeDataString(username)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task UpdateUserWithHttpMessagesAsync(string username, User body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); + _url = _url.Replace("{username}", Uri.EscapeDataString(username)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = SafeJsonConvert.SerializeObject(body, this.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); + _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "username"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("username", username); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteUser", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString(); + _url = _url.Replace("{username}", Uri.EscapeDataString(username)); + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new 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 this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 400 && (int)_statusCode != 404) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + 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; + } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2Extensions.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2Extensions.cs new file mode 100644 index 000000000000..6f8604077166 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2Extensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.PetstoreV2NoSync +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Models; + + /// + /// Extension methods for SwaggerPetstoreV2. + /// + public static partial class SwaggerPetstoreV2Extensions + { + /// + /// Add a new pet to the store + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The cancellation token. + /// + public static async Task AddPetAsync(this ISwaggerPetstoreV2 operations, Pet body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.AddPetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update an existing pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet object that needs to be added to the store + /// + /// + /// The cancellation token. + /// + public static async Task UpdatePetAsync(this ISwaggerPetstoreV2 operations, Pet body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.UpdatePetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// The operations group for this extension method. + /// + /// + /// Status values that need to be considered for filter + /// + /// + /// The cancellation token. + /// + public static async Task> FindPetsByStatusAsync(this ISwaggerPetstoreV2 operations, IList status, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.FindPetsByStatusWithHttpMessagesAsync(status, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, + /// tag3 for testing. + /// + /// The operations group for this extension method. + /// + /// + /// Tags to filter by + /// + /// + /// The cancellation token. + /// + public static async Task> FindPetsByTagsAsync(this ISwaggerPetstoreV2 operations, IList tags, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.FindPetsByTagsWithHttpMessagesAsync(tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Find pet by Id + /// + /// Returns a single pet + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet to return + /// + /// + /// The cancellation token. + /// + public static async Task GetPetByIdAsync(this ISwaggerPetstoreV2 operations, long petId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a pet in the store with form data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be updated + /// + /// + /// File to upload. + /// + /// + /// Updated name of the pet + /// + /// + /// Updated status of the pet + /// + /// + /// The cancellation token. + /// + public static async Task UpdatePetWithFormAsync(this ISwaggerPetstoreV2 operations, long petId, System.IO.Stream fileContent, string fileName = default(string), string status = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.UpdatePetWithFormWithHttpMessagesAsync(petId, fileContent, fileName, status, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// Pet id to delete + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task DeletePetAsync(this ISwaggerPetstoreV2 operations, long petId, string apiKey = "", CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.DeletePetWithHttpMessagesAsync(petId, apiKey, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> GetInventoryAsync(this ISwaggerPetstoreV2 operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetInventoryWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Place an order for a pet + /// + /// + /// The operations group for this extension method. + /// + /// + /// order placed for purchasing the pet + /// + /// + /// The cancellation token. + /// + public static async Task PlaceOrderAsync(this ISwaggerPetstoreV2 operations, Order body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PlaceOrderWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Find purchase order by Id + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other + /// values will generated exceptions + /// + /// The operations group for this extension method. + /// + /// + /// Id of pet that needs to be fetched + /// + /// + /// The cancellation token. + /// + public static async Task GetOrderByIdAsync(this ISwaggerPetstoreV2 operations, string orderId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOrderByIdWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete purchase order by Id + /// + /// For valid response try integer IDs with value < 1000. Anything above + /// 1000 or nonintegers will generate API errors + /// + /// The operations group for this extension method. + /// + /// + /// Id of the order that needs to be deleted + /// + /// + /// The cancellation token. + /// + public static async Task DeleteOrderAsync(this ISwaggerPetstoreV2 operations, string orderId, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.DeleteOrderWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// Created user object + /// + /// + /// The cancellation token. + /// + public static async Task CreateUserAsync(this ISwaggerPetstoreV2 operations, User body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.CreateUserWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + /// + /// The cancellation token. + /// + public static async Task CreateUsersWithArrayInputAsync(this ISwaggerPetstoreV2 operations, IList body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.CreateUsersWithArrayInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates list of users with given input array + /// + /// + /// The operations group for this extension method. + /// + /// + /// List of user object + /// + /// + /// The cancellation token. + /// + public static async Task CreateUsersWithListInputAsync(this ISwaggerPetstoreV2 operations, IList body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.CreateUsersWithListInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Logs user into the system + /// + /// + /// The operations group for this extension method. + /// + /// + /// The user name for login + /// + /// + /// The password for login in clear text + /// + /// + /// The cancellation token. + /// + public static async Task LoginUserAsync(this ISwaggerPetstoreV2 operations, string username, string password, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.LoginUserWithHttpMessagesAsync(username, password, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Logs out current logged in user session + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task LogoutUserAsync(this ISwaggerPetstoreV2 operations, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.LogoutUserWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get user by user name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + /// + /// The cancellation token. + /// + public static async Task GetUserByNameAsync(this ISwaggerPetstoreV2 operations, string username, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetUserByNameWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// name that need to be deleted + /// + /// + /// Updated user object + /// + /// + /// The cancellation token. + /// + public static async Task UpdateUserAsync(this ISwaggerPetstoreV2 operations, string username, User body, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.UpdateUserWithHttpMessagesAsync(username, body, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// + /// The operations group for this extension method. + /// + /// + /// The name that needs to be deleted + /// + /// + /// The cancellation token. + /// + public static async Task DeleteUserAsync(this ISwaggerPetstoreV2 operations, string username, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.DeleteUserWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false); + } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj b/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj index 4885670c6bdc..544e2165a1f1 100644 --- a/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj +++ b/AutoRest/Generators/CSharp/CSharp/AutoRest.Generator.CSharp.csproj @@ -36,7 +36,7 @@ True Resources.resx - + diff --git a/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs b/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs index 8655910279e8..5b3ba7981eb0 100644 --- a/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs +++ b/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs @@ -33,7 +33,8 @@ public CSharpCodeGenerator(Settings settings) : base(settings) /// Specifies mode for generating sync wrappers. /// [SettingsInfo("Specifies mode for generating sync wrappers.")] - public SyncWrapperGenerationMode SyncWrappers { get; set; } + [SettingsAlias("syncMethods")] + public SyncMethodsGenerationMode SyncMethods { get; set; } public override string Name { @@ -112,7 +113,7 @@ public override async Task Generate(ServiceClient serviceClient) { var extensionsTemplate = new ExtensionsTemplate { - Model = new ExtensionsTemplateModel(serviceClient, null, SyncWrappers), + Model = new ExtensionsTemplateModel(serviceClient, null, SyncMethods), }; await Write(extensionsTemplate, serviceClient.Name + "Extensions.cs"); } @@ -137,7 +138,7 @@ public override async Task Generate(ServiceClient serviceClient) // Service client extensions var operationExtensionsTemplate = new ExtensionsTemplate { - Model = new ExtensionsTemplateModel(serviceClient, group, SyncWrappers), + Model = new ExtensionsTemplateModel(serviceClient, group, SyncMethods), }; await Write(operationExtensionsTemplate, group + "Extensions.cs"); diff --git a/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs b/AutoRest/Generators/CSharp/CSharp/SyncMethodsGenerationMode.cs similarity index 89% rename from AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs rename to AutoRest/Generators/CSharp/CSharp/SyncMethodsGenerationMode.cs index 72e4088bb863..f8e3f6208201 100644 --- a/AutoRest/Generators/CSharp/CSharp/SyncWrapperGenerationMode.cs +++ b/AutoRest/Generators/CSharp/CSharp/SyncMethodsGenerationMode.cs @@ -7,7 +7,7 @@ namespace Microsoft.Rest.Generator.CSharp /// /// Defines supported modes for sync wrapper generation /// - public enum SyncWrapperGenerationMode + public enum SyncMethodsGenerationMode { Essential, All, diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs index 287311fe2708..596d49f15afb 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ExtensionsTemplateModel.cs @@ -10,7 +10,7 @@ namespace Microsoft.Rest.Generator.CSharp { public class ExtensionsTemplateModel : ServiceClient { - public ExtensionsTemplateModel(ServiceClient serviceClient, string operationName, SyncWrapperGenerationMode syncWrappers) + public ExtensionsTemplateModel(ServiceClient serviceClient, string operationName, SyncMethodsGenerationMode syncWrappers) { this.LoadFrom(serviceClient); MethodTemplateModels = new List(); diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs index 9c4c3ebcc37d..6a70892f725f 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs @@ -19,7 +19,7 @@ public MethodGroupTemplateModel(ServiceClient serviceClient, string methodGroupN MethodGroupName = methodGroupName; MethodGroupType = methodGroupName; Methods.Where(m => m.Group == MethodGroupName) - .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); + .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient, SyncMethodsGenerationMode.None))); } public List MethodTemplateModels { get; private set; } diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs index a5bfcd56b30a..0ba0a8d759df 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs @@ -14,10 +14,10 @@ namespace Microsoft.Rest.Generator.CSharp { public class MethodTemplateModel : Method { - public MethodTemplateModel(Method source, ServiceClient serviceClient, SyncWrapperGenerationMode syncWrappers) + public MethodTemplateModel(Method source, ServiceClient serviceClient, SyncMethodsGenerationMode syncWrappers) { this.LoadFrom(source); - SyncWrappers = syncWrappers; + SyncMethods = syncWrappers; ParameterTemplateModels = new List(); LogicalParameterTemplateModels = new List(); source.Parameters.ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p))); @@ -31,7 +31,7 @@ public MethodTemplateModel(Method source, ServiceClient serviceClient, SyncWrapp public bool IsCustomBaseUri { get; private set; } - public SyncWrapperGenerationMode SyncWrappers { get; private set; } + public SyncMethodsGenerationMode SyncMethods { get; private set; } public ServiceClient ServiceClient { get; set; } diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs index b38f1db38b18..9bd149a4dae8 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ServiceClientTemplateModel.cs @@ -16,7 +16,7 @@ public ServiceClientTemplateModel(ServiceClient serviceClient, bool internalCons this.LoadFrom(serviceClient); MethodTemplateModels = new List(); Methods.Where(m => m.Group == null) - .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient, SyncWrapperGenerationMode.None))); + .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient, SyncMethodsGenerationMode.None))); ConstructorVisibility = internalConstructors ? "internal" : "public"; this.IsCustomBaseUri = serviceClient.Extensions.ContainsKey(Microsoft.Rest.Generator.Extensions.ParameterizedHostExtension); } diff --git a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml index d2531c48e398..3a964744a4b4 100644 --- a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml +++ b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml @@ -6,10 +6,10 @@ @using Microsoft.Rest.Generator.Utilities @inherits Microsoft.Rest.Generator.Template @{ -if (Model.SyncWrappers == SyncWrapperGenerationMode.All || Model.SyncWrappers == SyncWrapperGenerationMode.Essential) -{ - if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) + if (Model.SyncMethods == SyncMethodsGenerationMode.All || Model.SyncMethods == SyncMethodsGenerationMode.Essential) { + if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) + { @:/// @:@WrapComment("/// ", String.IsNullOrEmpty(Model.Summary) ? Model.Description.EscapeXmlComment() : Model.Summary.EscapeXmlComment()) @:/// @@ -98,8 +98,8 @@ foreach (var parameter in Model.LocalParameters) } @:} -if (Model.SyncWrappers == SyncWrapperGenerationMode.All) -{ + if (Model.SyncMethods == SyncMethodsGenerationMode.All) + { @EmptyLine if (!String.IsNullOrEmpty(Model.Description) || !String.IsNullOrEmpty(Model.Summary)) { diff --git a/Tools/gulp/gulp-regenerate-expected.js b/Tools/gulp/gulp-regenerate-expected.js index 077960363b22..8f2bece72e3c 100644 --- a/Tools/gulp/gulp-regenerate-expected.js +++ b/Tools/gulp/gulp-regenerate-expected.js @@ -63,12 +63,17 @@ function gulpRegenerateExpected(options, done) { '-PayloadFlatteningThreshold', opts.flatteningThreshold, '-OutputDirectory', path.join(opts.outputDir, key), '-Input', (!!opts.inputBaseDir ? path.join(opts.inputBaseDir, mappingBaseDir) : mappingBaseDir), - '-Header', (!!opts.header ? opts.header : 'MICROSOFT_MIT_NO_VERSION') + '-Header', (!!opts.header ? opts.header : 'MICROSOFT_MIT_NO_VERSION') ]; if (opts.addCredentials) { args.push('-AddCredentials'); } + + if (opts.syncMethods) { + args.push('-SyncMethods'); + args.push(opts.syncMethods); + } if (!!opts.nsPrefix) { args.push('-Namespace'); diff --git a/gulpfile.js b/gulpfile.js index 85ef29e5d12d..22cc61f88101 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -296,7 +296,7 @@ gulp.task('regenerate:expected:java', function(cb){ }, cb); }) -gulp.task('regenerate:expected:csazure', ['regenerate:expected:csazurecomposite'], function (cb) { +gulp.task('regenerate:expected:csazure', ['regenerate:expected:csazurecomposite','regenerate:expected:csazureallsync', 'regenerate:expected:csazurenosync'], function (cb) { mappings = mergeOptions({ 'AcceptanceTests/AzureBodyDuration': '../../../TestServer/swagger/body-duration.json' }, defaultAzureMappings); @@ -312,7 +312,7 @@ gulp.task('regenerate:expected:csazure', ['regenerate:expected:csazurecomposite' }, cb); }); -gulp.task('regenerate:expected:cs', ['regenerate:expected:cswithcreds', 'regenerate:expected:cscomposite'], function (cb) { +gulp.task('regenerate:expected:cs', ['regenerate:expected:cswithcreds', 'regenerate:expected:cscomposite', 'regenerate:expected:csallsync', 'regenerate:expected:csnosync'], function (cb) { mappings = mergeOptions({ 'Mirror.RecursiveTypes': 'Swagger/swagger-mirror-recursive-type.json', 'Mirror.Primitives': 'Swagger/swagger-mirror-primitives.json', @@ -351,6 +351,78 @@ gulp.task('regenerate:expected:cswithcreds', function(cb){ }, cb); }); +gulp.task('regenerate:expected:csallsync', function(cb){ + mappings = mergeOptions( + { + 'PetstoreV2AllSync': 'Swagger/swagger.2.0.example.v2.json', + }); + + regenExpected({ + 'outputBaseDir': 'AutoRest/Generators/CSharp/CSharp.Tests', + 'inputBaseDir': 'AutoRest/Generators/CSharp/CSharp.Tests', + 'mappings': mappings, + 'outputDir': 'Expected', + 'codeGenerator': 'CSharp', + 'nsPrefix': 'Fixtures', + 'flatteningThreshold': '1', + 'syncMethods': 'all' + }, cb); +}); + +gulp.task('regenerate:expected:csnosync', function(cb){ + mappings = mergeOptions( + { + 'PetstoreV2NoSync': 'Swagger/swagger.2.0.example.v2.json', + }); + + regenExpected({ + 'outputBaseDir': 'AutoRest/Generators/CSharp/CSharp.Tests', + 'inputBaseDir': 'AutoRest/Generators/CSharp/CSharp.Tests', + 'mappings': mappings, + 'outputDir': 'Expected', + 'codeGenerator': 'CSharp', + 'nsPrefix': 'Fixtures', + 'flatteningThreshold': '1', + 'syncMethods': 'none' + }, cb); +}); + +gulp.task('regenerate:expected:csazureallsync', function(cb){ + mappings = mergeOptions( + { + 'AcceptanceTests/AzureBodyDurationAllSync': '../../../TestServer/swagger/body-duration.json' + }); + + regenExpected({ + 'outputBaseDir': 'AutoRest/Generators/CSharp/Azure.CSharp.Tests', + 'inputBaseDir': 'AutoRest/Generators/CSharp/Azure.CSharp.Tests', + 'mappings': mappings, + 'outputDir': 'Expected', + 'codeGenerator': 'Azure.CSharp', + 'nsPrefix': 'Fixtures', + 'flatteningThreshold': '1', + 'syncMethods': 'all' + }, cb); +}); + +gulp.task('regenerate:expected:csazurenosync', function(cb){ + mappings = mergeOptions( + { + 'AcceptanceTests/AzureBodyDurationNoSync': '../../../TestServer/swagger/body-duration.json' + }); + + regenExpected({ + 'outputBaseDir': 'AutoRest/Generators/CSharp/Azure.CSharp.Tests', + 'inputBaseDir': 'AutoRest/Generators/CSharp/Azure.CSharp.Tests', + 'mappings': mappings, + 'outputDir': 'Expected', + 'codeGenerator': 'Azure.CSharp', + 'nsPrefix': 'Fixtures', + 'flatteningThreshold': '1', + 'syncMethods': 'none' + }, cb); +}); + gulp.task('regenerate:expected:cscomposite', function (cb) { regenExpected({ 'outputBaseDir': 'AutoRest/Generators/CSharp/CSharp.Tests', From fbdcc2793288ee2e83971c0db72eb7927677bdb9 Mon Sep 17 00:00:00 2001 From: stankovski Date: Fri, 27 May 2016 15:31:49 -0700 Subject: [PATCH 22/23] Addressed fxcop issues --- .../CSharp/CSharp/GlobalSuppressions.cs | 5 +- .../TemplateModels/MethodTemplateModel.cs | 48 ++++++------------- .../Templates/ExtensionMethodTemplate.cshtml | 2 +- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/AutoRest/Generators/CSharp/CSharp/GlobalSuppressions.cs b/AutoRest/Generators/CSharp/CSharp/GlobalSuppressions.cs index e4ed9bd8b444..10c7165b62b2 100644 --- a/AutoRest/Generators/CSharp/CSharp/GlobalSuppressions.cs +++ b/AutoRest/Generators/CSharp/CSharp/GlobalSuppressions.cs @@ -64,8 +64,6 @@ MessageId = "Microsoft.Rest.Generator.Utilities.IndentedStringBuilder.AppendLine(System.String)", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.TemplateModels.ClientModelExtensions.#AppendConstraintValidations(System.String,System.Collections.Generic.Dictionary`2,Microsoft.Rest.Generator.Utilities.IndentedStringBuilder)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.MethodTemplateModel.#.ctor(Microsoft.Rest.Generator.ClientModel.Method,Microsoft.Rest.Generator.ClientModel.ServiceClient)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.MethodTemplateModel.#.ctor(Microsoft.Rest.Generator.ClientModel.Method,Microsoft.Rest.Generator.ClientModel.ServiceClient)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.ModelTemplateModel.#.ctor(Microsoft.Rest.Generator.ClientModel.CompositeType)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.MethodTemplateModel.#GroupedParameterTemplateModels")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.MethodTemplateModel.#LogicalParameterTemplateModels")] @@ -76,4 +74,7 @@ [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Rest.Generator.Utilities.IndentedStringBuilder.AppendLine(System.String)", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.ClientModelExtensions.#CheckNull(System.String,System.String)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Rest.Generator.Utilities.IndentedStringBuilder.AppendLine(System.String)", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.ClientModelExtensions.#ValidateType(Microsoft.Rest.Generator.ClientModel.IType,Microsoft.Rest.Generator.Utilities.IScopeProvider,System.String,System.Collections.Generic.Dictionary`2)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Rest.Generator.Utilities.IndentedStringBuilder.AppendLine(System.String)", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.ClientModelExtensions.#AppendConstraintValidations(System.String,System.Collections.Generic.Dictionary`2,Microsoft.Rest.Generator.Utilities.IndentedStringBuilder)")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.MethodTemplateModel.#.ctor(Microsoft.Rest.Generator.ClientModel.Method,Microsoft.Rest.Generator.ClientModel.ServiceClient,Microsoft.Rest.Generator.CSharp.SyncMethodsGenerationMode)")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.MethodTemplateModel.#.ctor(Microsoft.Rest.Generator.ClientModel.Method,Microsoft.Rest.Generator.ClientModel.ServiceClient,Microsoft.Rest.Generator.CSharp.SyncMethodsGenerationMode)")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.Rest.Generator.CSharp.MethodTemplateModel.#GetAsyncMethodInvocationArgs(System.String,System.String)")] diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs index 0ba0a8d759df..8e99ee936e92 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodTemplateModel.cs @@ -59,33 +59,8 @@ public string FailureStatusCodePredicate } return "!_httpResponse.IsSuccessStatusCode"; } - } - - /// - /// Generate the method parameter declarations for the sync extension - /// - public string SyncMethodParameterDeclaration - { - get - { - List declarations = new List(); - foreach (var parameter in LocalParameters) - { - string format = (parameter.IsRequired ? "{0} {1}" : "{0} {1} = {2}"); - string defaultValue = string.Format(CultureInfo.InvariantCulture, "default({0})", parameter.DeclarationExpression); - if (parameter.DefaultValue != null && parameter.Type is PrimaryType) - { - defaultValue = parameter.DefaultValue; - } - declarations.Add(string.Format(CultureInfo.InvariantCulture, - format, parameter.DeclarationExpression, parameter.Name, defaultValue )); - } - - return string.Join(", ", declarations); - } - } - - + } + /// /// Generate the method parameter declaration for async methods and extensions /// @@ -101,18 +76,25 @@ public virtual string GetAsyncMethodParameterDeclaration() /// Generated string of parameters public virtual string GetSyncMethodParameterDeclaration(bool addCustomHeaderParameters) { - var declarations = this.SyncMethodParameterDeclaration; - - if (!string.IsNullOrEmpty(declarations) && addCustomHeaderParameters) + List declarations = new List(); + foreach (var parameter in LocalParameters) { - declarations += ", "; + string format = (parameter.IsRequired ? "{0} {1}" : "{0} {1} = {2}"); + string defaultValue = string.Format(CultureInfo.InvariantCulture, "default({0})", parameter.DeclarationExpression); + if (parameter.DefaultValue != null && parameter.Type is PrimaryType) + { + defaultValue = parameter.DefaultValue; + } + declarations.Add(string.Format(CultureInfo.InvariantCulture, + format, parameter.DeclarationExpression, parameter.Name, defaultValue)); } + if (addCustomHeaderParameters) { - declarations += "Dictionary> customHeaders = null"; + declarations.Add("Dictionary> customHeaders = null"); } - return declarations; + return string.Join(", ", declarations); } /// diff --git a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml index 3a964744a4b4..09ba406f0844 100644 --- a/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml +++ b/AutoRest/Generators/CSharp/CSharp/Templates/ExtensionMethodTemplate.cshtml @@ -27,7 +27,7 @@ @:@WrapComment("/// ", parameter.Documentation.EscapeXmlComment()) @:/// } -@:public static @Model.ReturnTypeString @(Model.Name)(@Model.GetExtensionParameters(Model.SyncMethodParameterDeclaration)) +@:public static @Model.ReturnTypeString @(Model.Name)(@Model.GetExtensionParameters(Model.GetSyncMethodParameterDeclaration(false))) @:{ if (Model.ReturnType.Body != null) { From 85f149b697a0bd606350e487a590ee030a17cc20 Mon Sep 17 00:00:00 2001 From: stankovski Date: Fri, 27 May 2016 16:45:43 -0700 Subject: [PATCH 23/23] Addressed code review feedback --- AutoRest/Generators/CSharp/CSharp/CSharpCodeNamer.cs | 2 +- .../CSharp/CSharp/SyncMethodsGenerationMode.cs | 9 +++++++++ Documentation/cli.md | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/AutoRest/Generators/CSharp/CSharp/CSharpCodeNamer.cs b/AutoRest/Generators/CSharp/CSharp/CSharpCodeNamer.cs index 3504b01cb57d..2df4387d5bf2 100644 --- a/AutoRest/Generators/CSharp/CSharp/CSharpCodeNamer.cs +++ b/AutoRest/Generators/CSharp/CSharp/CSharpCodeNamer.cs @@ -14,7 +14,7 @@ public class CSharpCodeNamer : CodeNamer { private readonly HashSet _normalizedTypes; - [SettingsInfo("Whether to use DateTimeOffset instead of DateTime to model date-time types")] + [SettingsInfo("Indicates whether to use DateTimeOffset instead of DateTime to model date-time types")] public bool UseDateTimeOffset { get; set; } /// diff --git a/AutoRest/Generators/CSharp/CSharp/SyncMethodsGenerationMode.cs b/AutoRest/Generators/CSharp/CSharp/SyncMethodsGenerationMode.cs index f8e3f6208201..b4b75d02acd9 100644 --- a/AutoRest/Generators/CSharp/CSharp/SyncMethodsGenerationMode.cs +++ b/AutoRest/Generators/CSharp/CSharp/SyncMethodsGenerationMode.cs @@ -9,8 +9,17 @@ namespace Microsoft.Rest.Generator.CSharp /// public enum SyncMethodsGenerationMode { + /// + /// Default. Generates only one sync returning body or header. + /// Essential, + /// + /// Generates one sync method for each async method. + /// All, + /// + /// Does not generate any sync methods. + /// None } } diff --git a/Documentation/cli.md b/Documentation/cli.md index bd5f62c60210..6ffe3f7790b8 100644 --- a/Documentation/cli.md +++ b/Documentation/cli.md @@ -46,6 +46,15 @@ **-Azure.Python** Azure specific Python code generator. +##Code Generator Specific Settings +###CSharp + + **-SyncMethods** Specifies mode for generating sync wrappers. Supported value are `Essential` - generates only one sync returning body or header (default), `All` - generates one sync method for each async method, and `None` - does not generate any sync methods + + **-InternalConstructors** Indicates whether ctor needs to be generated with internal protection level. + + **-UseDateTimeOffset** Indicates whether to use DateTimeOffset instead of DateTime to model date-time types. + ##Examples - Generate C# client in MyNamespace from swagger.json input: