Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Swagger details for CheckNameAvailability API #4900

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"parameters":{
"subscriptionId":"77777777-b0c6-47a2-b37c-d8e65a629c18",
"api-version": "2016-06-01",
"location":"westus",
"input":{
"name":"swaggerExample",
"type": "Microsoft.RecoveryServices/Vaults"
}
},
"responses":{
"200":{
"body":{
"nameAvailable": true
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"parameters":{
"subscriptionId":"77777777-b0c6-47a2-b37c-d8e65a629c18",
"api-version": "2016-06-01",
"location":"westus",
"input":{
"name":"swaggerExample2",
"type": "Microsoft.RecoveryServices/Vaults"
}
},
"responses":{
"200":{
"body":{
"nameAvailable": false,
"reason": "AlreadyExists",
"message": "Resource already exists with the same name."
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@
"application/json"
],
"paths": {
"/subscriptions/{subscriptionId}/providers/Microsoft.RecoveryServices/locations/{location}/checkNameAvailability": {
"post": {
"tags": [
"CheckResourceNameAvailability"
],
"summary": "API to check for resource name availability.\r\nA name is available if no other resource exists that has the same SubscriptionId, Resource Name and Type\r\nor if one or more such resources exist, each of these must be GCed and their time of deletion be more than 24 Hours Ago",
"operationId": "CheckResourceNameAvailability_Post",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will generate a client named CheckResourceNameAvailability with one method Post which isn't a very good user experience. A better name would be something like RecoveryServices_CheckNameAvailability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in New PR: #5496

"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"$ref": "#/parameters/SubscriptionId"
},
{
"$ref": "#/parameters/ApiVersion"
},
{
"name": "location",
"in": "path",
"description": "Location of the resource",
"required": true,
"type": "string"
},
{
"name": "input",
"in": "body",
"description": "Contains information about Resource type and Resource name",
"required": true,
"schema": {
"$ref": "#/definitions/ResourceNameAvailabilityInput"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/ResourceNameAvailabilityResponseResource"
}
}
},
"x-ms-examples": {
"Availability status of Resource Name when no resource with same name, type and subscription exists, nor has been deleted within last 24 hours": {
"$ref": "./examples/CheckNameAvailability_Available.json"
},
"Availability status of Resource Name when resource with same name, type and subscription exists": {
"$ref": "./examples/CheckNameAvailability_NotAvailable.json"
}
}
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.RecoveryServices/vaults": {
"get": {
"tags": [
Expand Down Expand Up @@ -123,7 +178,7 @@
"deprecated": false,
"x-ms-pageable": {
"nextLinkName": "nextLink",
"itemName":"value"
"itemName": "value"
},
"x-ms-examples": {
"List of Recovery Services Resources in ResourceGroup": {
Expand Down Expand Up @@ -256,7 +311,7 @@
}
},
"deprecated": false,
"x-ms-examples":{
"x-ms-examples": {
"Delete Recovery Services Vault": {
"$ref": "./examples/DeleteVault.json"
}
Expand Down Expand Up @@ -589,6 +644,47 @@
},
"x-ms-azure-resource": true
},
"ResourceNameAvailabilityInput": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name should be CheckNameAvailabilityParameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in New PR: #5496

"description": "Resource information, as sent to the regional resource provider from Global RP.",
"type": "object",
"properties": {
"type": {
"type": "string"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is type, would it make more sense to be an enum? Perhaps a better description would help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the Resource Type: Microsoft.RecoveryServices/vaults. Added the description above in new PR: #5496

},
"name": {
"type": "string"
}
}
},
"ResourceNameAvailabilityResponse": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be its own model, can't these fields be embedded directly in the parent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fields present in the response are completely different to that in the parent.

"description": "Response for check name availability API. Resource provider will set availability as true | false.",
"type": "object",
"properties": {
"nameAvailable": {
"type": "boolean"
},
"reason": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"ResourceNameAvailabilityResponseResource": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CheckNameAvailabilityResult

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in New PR: #5496

"description": "Response for check name availability API. Resource provider will set availability as true | false.",
"allOf": [
{
"$ref": "#/definitions/Resource"
}
],
"properties": {
"properties": {
"$ref": "#/definitions/ResourceNameAvailabilityResponse",
"description": "ResourceNameAvailabilityResponseResource properties"
}
}
},
"Sku": {
"description": "Identifies the unique system identifier for each Azure resource.",
"required": [
Expand Down Expand Up @@ -621,7 +717,7 @@
"$ref": "#/definitions/Resource"
}
],
"properties":{
"properties": {
"location": {
"description": "Resource location.",
"type": "string"
Expand All @@ -643,7 +739,7 @@
"$ref": "#/definitions/Resource"
}
],
"properties":{
"properties": {
"location": {
"description": "Resource location.",
"type": "string"
Expand Down
10 changes: 10 additions & 0 deletions specification/recoveryservices/resource-manager/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ openapi-type: arm
tag: package-2016-06
```

### Validations
Run validations when `--validate` is specified on command line

``` yaml $(validate)
azure-validator: true
model-validator: true
semantic-validator: true
message-format: json
```

### Tag: package-2016-06

These settings apply only when `--tag=package-2016-06` is specified on the command line.
Expand Down