Skip to content

Conversation

@vivsriaus
Copy link
Contributor

@vivsriaus vivsriaus commented Aug 24, 2017

Add policy set definition APIs, add notScopes to policy assignment, add policyMode to policy definition, update the api-version

This checklist is used to make sure that common issues in a pull request are addressed. This will expedite the process of getting your pull request merged and avoid extra work on your part to fix issues discovered during the review process.

PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • Except for special cases involving multiple contributors, the PR is started from a fork of the main repository, not a branch.
  • If applicable, the PR references the bug/issue that it fixes.
  • Swagger files are correctly named (e.g. the api-version in the path should match the api-version in the spec).

Quality of Swagger

@vivsriaus
Copy link
Contributor Author

@gandhiniraj @cyl3392207 Please review this one instead @vishrutshah Mike and Niraj are from the ARM team, who can review this. So is @brendandburns who signed off on the previous PR

@vishrutshah
Copy link
Contributor

@veronicagg Taking it over to my plate as i made them close and re-open new one :)

@vivsriaus Thanks for adding two commits. We'll review it as soon as ARM team signs-off.

@vishrutshah vishrutshah added ARM WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required labels Aug 25, 2017
@vishrutshah
Copy link
Contributor

@ravbhatnagar Let me know if this has been gone through ARM sign-off.

@vivsriaus Meanwhile, would you mind please providing us with the x-ms-examples for new operations to help us with model validation. Thanks!

@vivsriaus
Copy link
Contributor Author

@vishrutshah Examples added. Thanks for catching that!

@vivsriaus
Copy link
Contributor Author

@vishrutshah Let me know if this looks good to be merged. Thanks

@vishrutshah
Copy link
Contributor

@ravbhatnagar Could you please review this from ARM perspective, please? Thanks!

},
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments": {
},
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments": {
Copy link
Contributor

Choose a reason for hiding this comment

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

camelcase policyAssignments

}
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policysetdefinitions/{policySetDefinitionName}": {
Copy link
Contributor

Choose a reason for hiding this comment

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

camelcasing

"$ref": "#/definitions/PolicySetDefinitionProperties",
"description": "The policy definition properties."
},
"id": {
Copy link
Contributor

Choose a reason for hiding this comment

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

read only

"type": "string",
"description": "The ID of the policy set definition."
},
"name": {
Copy link
Contributor

Choose a reason for hiding this comment

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

read only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

name should be settable

Copy link
Contributor

Choose a reason for hiding this comment

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

name comes from the URL. It is not settable in the request body

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can pass name in the request body, and we throw an error when the passed in name doesn't match what is in the Url

"type": "string",
"description": "The name of the policy set definition. If you do not specify a value for name, the value is inferred from the name value in the request URI."
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

type property missing.

},
"x-ms-odata": "#/definitions/PolicySetDefinition"
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Patch API missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a PATCH in our source code

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

"$ref": "#/parameters/SubscriptionIdParameter"
}
],
"responses": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a default response to capture all the error responses. The shape of the error object complies with RPC. Example here - https://github.com/Azure/azure-rest-api-specs/blob/current/specification/batch/resource-manager/Microsoft.Batch/2017-05-01/BatchManagement.json#L101

"$ref": "#/parameters/SubscriptionIdParameter"
}
],
"responses": {
Copy link
Contributor

Choose a reason for hiding this comment

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

The description of 204 can state that the policysetDefinition does not exist in the subscription

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We usually use the http code description in our specs, so I'm keeping it consistent across the board. For instance, like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is something that we can improve across the board then. Lets start with the new APIs we are adding. More/clear description is always better :)

"description": "Gets all the policy set definitions for a subscription.",
"parameters": [
{
"name": "$filter",
Copy link
Contributor

Choose a reason for hiding this comment

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

What is supported through $filter. It would be good if the common cases are called out in the description.

"description": "The policy definition properties."
},
"PolicySetDefinitionProperties": {
"properties": {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need a provisioningState property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need it

Copy link
Contributor

Choose a reason for hiding this comment

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

If the creates are not long running than its fine.

@ravbhatnagar ravbhatnagar added ReadyForSDKReview and removed WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required labels Aug 29, 2017
@vivsriaus
Copy link
Contributor Author

@vishrutshah The CI is failing because it says ErrorResponse is not allowed as part of responses? We had default error responses for our other spec file (here) and didn't receive any validation errors then. Can you please take a look?

},
"parameters": {
"type": "object",
"description": "Required if a parameter is used in policy rule."
Copy link
Contributor

Choose a reason for hiding this comment

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

This description should be updated as it is not applicable to setDefinitions. Should be something along the lines of "The policy set definition parameters that can be used in policy definition references"

"swagger": "2.0",
"info": {
"title": "PolicyClient",
"version": "2017-06-01-preview",
Copy link
Contributor

Choose a reason for hiding this comment

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

policyDefinitions don't have this api-version (though they probably should have with mode added). I think that means you need to split out the swagger specs from 2016-12-01 and combine policyDefinitions there with policyAssignments and policySetDefinitions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand. policyDefinitions APIs won't work with 2017-06-01-preview version?

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct, api-versions are resourceType specific and policyDefinitions did not have a change that the people who made the changes thought warranted a new api-version. Calls to its APIs with 2017-06-01-preview will not work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. Before I go ahead and do the split, shouldn't we bump the api-version for policyDefinitions as well, now that we have mode?

Copy link
Contributor

@pilor pilor Sep 6, 2017

Choose a reason for hiding this comment

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

Mode was already released to prod on all existing api-versions so it could be even more breaking to restrict it now (even though its probably not used by anyone yet). There is the option of introducing a new api-version on policyDefinitions just to make this work easier but I don't know if that's a great idea. It will be good to have them split in the future so they can be incremented individually when needed. If everything gets a new api-version every time anything changes you end up with a ton of api-versions that user has to wade through.

See Microsoft.SQL for an example of resource types that were split out into their own swagger specs

"description": "Policies required to minimize the risk of accidental cost overruns",
"metadata": {
"category": "Cost Management"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

example should include parameters since they are typically the most complex part of these objects

"parameters": {
"listOfAllowedSKUs": {
"value": [
"“Standard_GRS”",
Copy link
Contributor

Choose a reason for hiding this comment

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

both of these values should just have 1 "

"parameters": {
"listOfAllowedSKUs": {
"value": [
"“Standard_GRS”",
Copy link
Contributor

Choose a reason for hiding this comment

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

single "

"type": "string",
"description": "The display name of the policy definition."
},
"description": {
Copy link
Contributor

Choose a reason for hiding this comment

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

policyDefinition supports metadata now

},
"description": "The policy's excluded scopes."
},
"parameters": {
Copy link
Contributor

Choose a reason for hiding this comment

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

policyAssignment supports metadata

},
"policyDefinitionId": {
"type": "string",
"description": "The ID of the policy definition."
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the description be "The ID of the policy definition or policy set definition"

@@ -0,0 +1,44 @@
{
"parameters": {
Copy link
Contributor

Choose a reason for hiding this comment

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

these example files need to be referenced in the swagger spec for them to show up in documentation, right? See https://github.com/pilor/azure-rest-api-specs/blob/current/documentation/x-ms-examples.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course they should! thanks for catching this

@@ -0,0 +1,1102 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

This new spec needs to be added to the root readme.md to have it included in autorest packages, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

Copy link
Contributor

@vishrutshah vishrutshah left a comment

Choose a reason for hiding this comment

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

Left some minor comments. I'll wait for the build to complete to check on validation results on semantic, model and linter results.

- Microsoft.Authorization/2015-01-01/locks.json
```

### Tag: package-policy-2017-06
Copy link
Contributor

Choose a reason for hiding this comment

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

Will you be having the api-version 2017-06-01 in future without -preview in api-version? In that case, I'd recommend tag to reflect the -preview.

],
"responses": {
"204": {
"description": "No Content"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please provide better descriptions as per recommendation from Gaurav that'd not only help SDK but also better API documentations as well

],
"responses": {
"200": {
"description": "OK - Returns ana array of policy definitions.",
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in ana

Copy link
Contributor

@vishrutshah vishrutshah left a comment

Choose a reason for hiding this comment

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

Please review model validation errors https://travis-ci.org/Azure/azure-rest-api-specs/jobs/272643689#L670 Thanks!

"description": "The policy definition.",
"x-ms-azure-resource": true
},
"PolicySetDefinition": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this model is missing property named as type from the example.

https://travis-ci.org/Azure/azure-rest-api-specs/jobs/272643689#L691

"policyDefinitionId": "/subscriptions/subid/providers/Microsoft.Authorization/policyDefinitions/storageSkus",
"parameters": {
"allowedLocations": {
"value": [
Copy link
Contributor

Choose a reason for hiding this comment

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

To make this clear and valid can you change this to "parameters": { "validLocations": { "value": "[parameters('allowedLocations')]" } }?

- Microsoft.Authorization/2015-01-01/locks.json
```

### Tag: package-policy-2017-06
Copy link
Contributor

Choose a reason for hiding this comment

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

line 40 should change to reference this new tag

Copy link
Contributor

@pilor pilor left a comment

Choose a reason for hiding this comment

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

Just added 2 more minor comments

@azuresdkciprbot
Copy link

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/resources/resource-manager/readme.md
Before the PR: Warning(s): 28 Error(s): 47
After the PR: Warning(s): 0 Error(s): 0

AutoRest Linter Guidelines | AutoRest Linter Issues

Send feedback and make AutoRest Linter Azure Bot smarter day by day!

Thanks for your co-operation.

@vishrutshah
Copy link
Contributor

Please review the model validation error here https://travis-ci.org/Azure/azure-rest-api-specs/jobs/273107502#L715

@vivsriaus
Copy link
Contributor Author

@vishrutshah the error says valid example for response 200 is missing for createOrUpdatePolicySetDefinition. The response would be the same, so I don't think it warrants a separate example. Agree?

@vivsriaus
Copy link
Contributor Author

@vishrutshah can you please look into this?

@vishrutshah
Copy link
Contributor

Hi @vivsriaus, regarding

the error says valid example for response 200 is missing for createOrUpdatePolicySetDefinition. The response would be the same, so I don't think it warrants a separate example. Agree?

We'd like to make the examples complete. That menas that you'd define the sample responses for all the response code defined in the swagger. Otherwise tool cannot validate whether provided example is complete or not just based on the model are same. It's be great if you can provide sample response in example for code 200 as well as that is one of the positive response code defined in swagger and model validator would like to validate, please. Thanks! Other changes LGTM!

@azuresdkciprbot
Copy link

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/resources/resource-manager/readme.md
Before the PR: Warning(s): 28 Error(s): 47
After the PR: Warning(s): 0 Error(s): 0

AutoRest Linter Guidelines | AutoRest Linter Issues

Send feedback and make AutoRest Linter Azure Bot smarter day by day!

Thanks for your co-operation.

@ravbhatnagar ravbhatnagar added the ARMSignedOff <valid label in PR review process>add this label when ARM approve updates after review label Sep 11, 2017
@vishrutshah vishrutshah merged commit 40e8139 into Azure:current Sep 11, 2017
@AutorestCI
Copy link

@AutorestCI
Copy link

No modification for AutorestCI/azure-sdk-for-node

@AutorestCI
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ARM ARMSignedOff <valid label in PR review process>add this label when ARM approve updates after review ReadyForSDKReview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants