diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Expected/Redis/2016-04-01/Microsoft.Cache.json b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Expected/Redis/2016-04-01/Microsoft.Cache.json
index f94006e8ae8dd..98cde9c84d6b2 100644
--- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Expected/Redis/2016-04-01/Microsoft.Cache.json
+++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Expected/Redis/2016-04-01/Microsoft.Cache.json
@@ -109,11 +109,27 @@
"description": "The number of shards to be created on a Premium Cluster Cache."
},
"subnetId": {
- "type": "string",
+ "oneOf": [
+ {
+ "type": "string",
+ "pattern": "^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$"
+ },
+ {
+ "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression"
+ }
+ ],
"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",
+ "oneOf": [
+ {
+ "type": "string",
+ "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$"
+ },
+ {
+ "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression"
+ }
+ ],
"description": "Required when deploying a redis cache inside an existing Azure Virtual Network."
}
},
diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/Redis/2016-04-01/redis.json b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/Redis/2016-04-01/redis.json
index ffb846962c877..3729bbf88b2e4 100644
--- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/Redis/2016-04-01/redis.json
+++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Swagger/Redis/2016-04-01/redis.json
@@ -453,6 +453,125 @@
}
}
}
+ },
+ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default": {
+ "put": {
+ "tags": [
+ "Redis"
+ ],
+ "operationId": "PatchSchedules_CreateOrUpdate",
+ "description": "Create or replace the patching schedule for redis 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/RedisPatchSchedulesRequest"
+ },
+ "description": "Parameters to set patch schedules for redis cache."
+ },
+ {
+ "$ref": "#/parameters/ApiVersionParameter"
+ },
+ {
+ "$ref": "#/parameters/SubscriptionIdParameter"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/RedisPatchSchedulesResponse"
+ }
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "Redis"
+ ],
+ "operationId": "PatchSchedules_Delete",
+ "description": "Deletes the patching schedule for redis 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."
+ },
+ {
+ "$ref": "#/parameters/ApiVersionParameter"
+ },
+ {
+ "$ref": "#/parameters/SubscriptionIdParameter"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": ""
+ }
+ }
+ },
+ "get": {
+ "tags": [
+ "Redis"
+ ],
+ "operationId": "PatchSchedules_Get",
+ "description": "Gets the patching schedule for redis 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."
+ },
+ {
+ "$ref": "#/parameters/ApiVersionParameter"
+ },
+ {
+ "$ref": "#/parameters/SubscriptionIdParameter"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Response of Get patch schedules.",
+ "schema": {
+ "$ref": "#/definitions/RedisPatchSchedulesResponse"
+ }
+ }
+ }
+ }
}
},
"definitions": {
@@ -531,10 +650,12 @@
},
"subnetId": {
"type": "string",
+ "pattern": "^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$",
"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",
+ "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$",
"description": "Required when deploying a redis cache inside an existing Azure Virtual Network."
}
},
@@ -794,6 +915,98 @@
"files"
],
"description": "Parameters for redis import operation."
+ },
+ "ScheduleEntry": {
+ "properties": {
+ "dayOfWeek": {
+ "type": "string",
+ "description": "Day of week when cache can be patched.",
+ "enum": [
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday",
+ "Sunday"
+ ],
+ "x-ms-enum": {
+ "name": "DayOfWeek",
+ "modelAsString": true
+ }
+ },
+ "startHourUtc": {
+ "type": "integer",
+ "format": "int32",
+ "description": "Start hour after which cache patching can start."
+ },
+ "maintenanceWindow": {
+ "type": "string",
+ "format": "duration",
+ "description": "ISO8601 timespan specifying how much time cache patching can take. "
+ }
+ },
+ "required": [
+ "dayOfWeek",
+ "startHourUtc"
+ ]
+ },
+ "ScheduleEntries": {
+ "properties": {
+ "scheduleEntries": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ScheduleEntry"
+ },
+ "description": "List of patch schedules for redis cache."
+ }
+ },
+ "required": [
+ "scheduleEntries"
+ ],
+ "description": "List of patch schedules for redis cache."
+ },
+ "RedisPatchSchedulesRequest": {
+ "properties": {
+ "properties": {
+ "x-ms-client-flatten": true,
+ "$ref": "#/definitions/ScheduleEntries",
+ "description": "List of patch schedules for redis cache."
+ }
+ },
+ "required": [
+ "properties"
+ ],
+ "description": "Parameters to set patch schedules for redis cache."
+ },
+ "RedisPatchSchedulesResponse": {
+ "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"
+ },
+ "properties": {
+ "x-ms-client-flatten": true,
+ "$ref": "#/definitions/ScheduleEntries",
+ "description": "List of patch schedules for redis cache."
+ }
+ },
+ "description": "Response to put/get patch schedules for redis cache."
}
},
"parameters": {
diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/JsonSchema.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/JsonSchema.cs
index c2981c23ac17c..139d76dcd200d 100644
--- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/JsonSchema.cs
+++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/JsonSchema.cs
@@ -93,6 +93,11 @@ public string ResourceType
///
public double? Maximum { get; set; }
+ ///
+ /// The regular expression pattern that a string value matching this schema must match.
+ ///
+ public string Pattern { get; set; }
+
///
/// The schema that matches additional properties that have not been specified in the
/// Properties dictionary.
@@ -301,6 +306,7 @@ public JsonSchema Clone()
result.AdditionalProperties = Clone(AdditionalProperties);
result.Minimum = Minimum;
result.Maximum = Maximum;
+ result.Pattern = Pattern;
result.enumList = Clone(Enum);
result.properties = Clone(Properties);
result.requiredList = Clone(Required);
@@ -380,7 +386,8 @@ public override bool Equals(object obj)
Equals(Required, rhs.Required) &&
Equals(Description, rhs.Description) &&
Equals(Minimum, rhs.Minimum) &&
- Equals(Maximum, rhs.Maximum);
+ Equals(Maximum, rhs.Maximum) &&
+ Equals(Pattern, rhs.Pattern);
}
return result;
@@ -399,7 +406,8 @@ public override int GetHashCode()
GetHashCode(Required) ^
GetHashCode(Description) ^
GetHashCode(Minimum) ^
- GetHashCode(Maximum);
+ GetHashCode(Maximum) ^
+ GetHashCode(Pattern);
}
private static int GetHashCode(object value)
diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaParser.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaParser.cs
index 374cbcb2911c9..5e8ab6a366d0c 100644
--- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaParser.cs
+++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaParser.cs
@@ -484,6 +484,11 @@ private static JsonSchema ParsePrimaryType(Property property, PrimaryType primar
result.Maximum = Double.Parse(entry.Value, CultureInfo.CurrentCulture);
break;
+ case Constraint.Pattern:
+ Debug.Assert(result.JsonType == "string", "Expected to only find a Pattern constraint on a string property.");
+ result.Pattern = entry.Value;
+ break;
+
default:
Debug.Fail("Unrecognized property Constraint: " + entry.Key);
break;
diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaWriter.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaWriter.cs
index c89f3f490a676..4925445d6f8f6 100644
--- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaWriter.cs
+++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchemaWriter.cs
@@ -80,7 +80,8 @@ private static void WriteDefinitionMap(JsonWriter writer, string definitionMapNa
(definition.Enum != null &&
definition.Enum.Count() > 0 &&
definitionName != "type" &&
- definitionName != "apiVersion")) &&
+ definitionName != "apiVersion") ||
+ (definition.Pattern != null)) &&
(definition.JsonType != "array" ||
(definitionName != "resources"));
@@ -148,6 +149,7 @@ private static void WriteDefinition(JsonWriter writer, JsonSchema definition)
WriteProperty(writer, "type", definition.JsonType);
WriteProperty(writer, "minimum", definition.Minimum);
WriteProperty(writer, "maximum", definition.Maximum);
+ WriteProperty(writer, "pattern", definition.Pattern);
WriteStringArray(writer, "enum", definition.Enum);
WriteDefinitionArray(writer, "oneOf", definition.OneOf);
WriteProperty(writer, "format", definition.Format);