Search SDK: Adding arm-search spec for 2015-08-19 API version#637
Conversation
This spec covers all functionality of the Azure Search Management REST API version 2015-08-19, including key management and search service management, provisioning, and scaling.
This is part 1 of a final pass over the Swagger spec for arm-search. Types of
issues that are addressed include:
- Consistency of parameter names (serviceName -> searchServiceName).
- Consistency of method names with established Azure conventions
(List -> ListByResourceGroup, etc.).
- Added the ability to pass in x-ms-client-request-id (test coverage still
pending).
- Correctly modeled error cases for all key management operations.
- Enabled paging for List operations (although the Search RP doesn't support
paging, we at least benefit from the improved client programming model).
Part 2 will address the same sorts of issues in Search service management
operations.
| ], | ||
| "x-ms-pageable": { | ||
| "nextLinkName": null | ||
| }, |
There was a problem hiding this comment.
Listing services inside resource group will never return more than one page of results?
There was a problem hiding this comment.
As implemented in our RP currently, no it won't.
|
FYI @tbombach |
|
We'll be replacing the externalDocs links to MSDN as soon as we have new content (or at least aka.ms links) to replace it. |
The aka.ms links still point to MSDN, but they'll be updated to docs.microsoft.com after the migration.
tbombach
left a comment
There was a problem hiding this comment.
The JSON constraints aren't a "must-have" for merging (especially not a regex pattern that covers the rules for dashes).
The only question I have before merging is around use of enums - is it fine that the client will be unable to handle new values for that property? It would take a major version bump in the SDKs to support a new value (since enum additions are considered breaking changes in strongly typed languages). If you want to minimize breaking changes, then modeling as string will do that.
| ], | ||
| "properties": { | ||
| "name": { | ||
| "description": "The Search service name to validate. Search service names must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and must be between 2 and 60 characters in length.", |
There was a problem hiding this comment.
It's nice that these constraints are described, but should they also be JSON constraints? The regex pattern might be complicated to do, but the min/max string constraints wouldn't be difficult.
There was a problem hiding this comment.
What's the purpose of the regex? If it's for codegen, I'm not sure it's worth duplicating the validation logic as our service already does that. If it's for documentation, I think English prose works better than regexes anyway.
There was a problem hiding this comment.
The benefit is that validation would fail before a call is made the service.
The constraints (including regex pattern) get turned into checks in the Validate() method: https://github.com/Azure/azure-sdk-for-net/blob/04d78e2101f7d040aaa97481757a2fb69fffe9c9/src/Search/Microsoft.Azure.Search/GeneratedSearchService/Models/StandardAnalyzer.cs#L65
That get called when making requests: https://github.com/Azure/azure-sdk-for-net/blob/04d78e2101f7d040aaa97481757a2fb69fffe9c9/src/Search/Microsoft.Azure.Search/GeneratedSearchService/DataSourcesOperations.cs#L102
That way a call would fail fast with a ValidationException, rather than making an actual call to the service and waiting for a response. The goal is to do client-side validation to the best of our ability, even though there's already server-side validation. It's also easier for a user writing code that uses the client - the response from the service is probably some variation of a 4xx Bad Request, while a ValidationException contains the regex pattern that failed and the target property that failed the pattern. If you rely on the response, then the customer code has to parse the message on the CloudError to find the problem.
There was a problem hiding this comment.
This seems like solving the problem at the wrong layer. It introduces unnecessary coupling between the service and the client. Consider versioning -- What if we discover a bug in the regex and fix it in our RP, but forget to fix it in the client? Or maybe we fix it in both places, but some customers are still using an older client with the wrong regex. This kind of coupling seems like too high a price to pay just to shave off some latency in an error case.
Regarding usability, here is the experience of providing an invalid service name today:
[Fact]
public void CreateServiceWithInvalidNameGivesUsefulMessage()
{
Run(() =>
{
SearchManagementClient searchMgmt = GetSearchManagementClient();
SearchService service = DefineServiceWithSku(SkuName.Free);
CloudException e =
Assert.Throws<CloudException>(() => searchMgmt.Services.CreateOrUpdate(Data.ResourceGroupName, InvalidServiceName, service));
Assert.Equal("Service name '----badname' is invalid: Service name must only contain lowercase letters, digits or dashes, cannot start or end with or contain consecutive dashes and is limited to 60 characters.", e.Message);
});
}If need be, we can include the regex in the error message, but for most users this won't make much sense.
| ], | ||
| "x-ms-enum": { | ||
| "name": "SkuName", | ||
| "modelAsString": false |
There was a problem hiding this comment.
One note with modelAsString: false is if a new value is ever added, the client will be unable to handle it. When trying to deserialize the name property, it will be unable to map any values not listed here to a correct enum value (for languages that use real enums).
There was a problem hiding this comment.
Good point. One thing I don't like about modelAsString though is that it breaks Intellisense. In our data plane SDK, I created an "extensible enum" pattern to handle this, but I haven't had time to try to fold it back into AutoRest.
How about this... Since we don't plan to add any SKUs in the near future, let's leave it like this for now, and I'll use the addition of a new SKU as a forcing function add extensible enums to AutoRest. Sound good?
There was a problem hiding this comment.
Yes, I think that's our currently only supported way of having the desired Intellisense experience for a set of known values. Let's leave it that way for now with the knowledge that a major version bump for SDKs would be required once SKU is expanded (or the extensible enums that you mentioned).
|
I decided to add some JSON examples to the spec... Please hold off merging for now. Thanks! |
|
@HeidiSteen I ended up adding the examples after all, since it's possible to have different examples for the request & response. @tbombach I'm ready for this to be merged now, assuming you agree with my comments above. |
|
Thanks for the update @brjohnstmsft. The enum plan makes sense. I left another comment re: the regex constraint. |
|
@tbombach Replied to your comment above. |
|
No modification for Ruby |
|
No modification for NodeJS |
|
No modification for Python |
| "description": "Input of check name availability API." | ||
| "description": "Input of check name availability API.", | ||
| "example": { | ||
| "name": "azs-test", |
There was a problem hiding this comment.
Do we want to use the azs- convention here?
There was a problem hiding this comment.
Good point... probably not
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
api-versionin the path should match theapi-versionin the spec).Quality of Swagger
FYI @chaosrealm @seansaleh @HeidiSteen @EvanBoyle @jack4it
This change is