Skip to content

Fix for Adding API Version 2022-06-01 for PriceSheets and Operations#21560

Closed
prchalla1 wants to merge 30 commits intoAzure:mainfrom
prchalla1:dev-consumption-Microsoft.Consumption-2022-06-01
Closed

Fix for Adding API Version 2022-06-01 for PriceSheets and Operations#21560
prchalla1 wants to merge 30 commits intoAzure:mainfrom
prchalla1:dev-consumption-Microsoft.Consumption-2022-06-01

Conversation

@prchalla1
Copy link
Contributor

@prchalla1 prchalla1 commented Nov 15, 2022

ARM API Information (Control Plane)

MSFT employees can try out our new experience at OpenAPI Hub - one location for using our validation tools and finding your workflow.

Azure 1st Party Service can try out the Shift Left experience to initiate API design review from ADO code repo. If you are interested, may request engineering support by filling in with the form https://aka.ms/ShiftLeftSupportForm.

Changelog

Add a changelog entry for this PR by answering the following questions:

  1. What's the purpose of the update?
    • new service onboarding
    • new API version
    • update existing version for new feature
    • update existing version to fix swagger quality issue in s360
    • Other, please clarify
  2. When are you targeting to deploy the new service/feature to public regions? Please provide the date or, if the date is not yet available, the month.
  3. When do you expect to publish the swagger? Please provide date or, the the date is not yet available, the month.
  4. By default, Azure SDKs of all languages (.NET/Python/Java/JavaScript for both management-plane SDK and data-plane SDK, Go for management-plane SDK only ) MUST be refreshed with/after swagger of new version is published. If you prefer NOT to refresh any specific SDK language upon swagger updates in the current PR, please leave details with justification here.

Contribution checklist (MS Employees Only):

If any further question about AME onboarding or validation tools, please view the FAQ.

ARM API Review Checklist

Applicability: ⚠️

If your changes encompass only the following scenarios, you should SKIP this section, as these scenarios do not require ARM review.

  • Change to data plane APIs
  • Adding new properties
  • All removals

Otherwise your PR may be subject to ARM review requirements. Complete the following:

  • Check this box if any of the following apply to the PR so that the label "ARMReview" and "WaitForARMFeedback" will be added by bot to kick off ARM API Review. Missing to check this box in the following scenario may result in delays to the ARM manifest review and deployment.

    • Adding a new service
    • Adding new API(s)
    • Adding a new API version
      -[ ] To review changes efficiently, ensure you copy the existing version into the new directory structure for first commit and then push new changes, including version updates, in separate commits. You can use OpenAPIHub to initialize the PR for adding a new version. For more details refer to the wiki.
  • Ensure you've reviewed following guidelines including ARM resource provider contract and REST guidelines. Estimated time (4 hours). This is required before you can request review from ARM API Review board.

  • If you are blocked on ARM review and want to get the PR merged with urgency, please get the ARM oncall for reviews (RP Manifest Approvers team under Azure Resource Manager service) from IcM and reach out to them.

Breaking Change Review Checklist

If you have any breaking changes as defined in the Breaking Change Policy, request approval from the Breaking Change Review Board.

Action: to initiate an evaluation of the breaking change, create a new intake using the template for breaking changes. Additional details on the process and office hours are on the Breaking Change Wiki.

NOTE: To update API(s) in public preview for over 1 year (refer to Retirement of Previews)

Please follow the link to find more details on PR review process.

@prchalla1 prchalla1 requested a review from kjeur as a code owner November 15, 2022 21:32
@openapi-workflow-bot
Copy link

Hi, @prchalla1 Thanks for your PR. I am workflow bot for review process. Here are some small tips.

  • Please ensure to do self-check against checklists in first PR comment.
  • PR assignee is the person auto-assigned and responsible for your current PR reviewing and merging.
  • For specs comparison cross API versions, Use API Specs Comparison Report Generator
  • If there is CI failure(s), to fix CI error(s) is mandatory for PR merging; or you need to provide justification in PR comment for explanation. How to fix?

  • Any feedback about review process or workflow bot, pls contact swagger and tools team. vscswagger@microsoft.com

    @openapi-pipeline-app
    Copy link

    openapi-pipeline-app bot commented Nov 15, 2022

    Swagger Validation Report

    ️️✔️BreakingChange succeeded [Detail] [Expand]
    There are no breaking changes.
    ️🔄Breaking Change(Cross-Version) inProgress [Detail]
    ️⌛CredScan pending [Detail]
    ️🔄LintDiff inProgress [Detail]
    ️⚠️Avocado: 1 Warnings warning [Detail]
    Rule Message
    ⚠️ MULTIPLE_API_VERSION The default tag contains multiple API versions swaggers.
    readme: specification/consumption/resource-manager/readme.md
    tag: specification/consumption/resource-manager/readme.md#tag-package-2022-06
    ️🔄ApiReadinessCheck inProgress [Detail]
    ️🔄~[Staging] ServiceAPIReadinessTest inProgress [Detail]
    ️🔄~[Staging] SwaggerAPIView inProgress [Detail]
    ️️✔️ModelValidation succeeded [Detail] [Expand]
    Validation passes for ModelValidation.
    ️️✔️SemanticValidation succeeded [Detail] [Expand]
    Validation passes for SemanticValidation.
    ️⌛PoliCheck pending [Detail]
    ️🔄PrettierCheck inProgress [Detail]
    ️️✔️SpellCheck succeeded [Detail] [Expand]
    Validation passes for SpellCheck.
    ️🔄Lint(RPaaS) inProgress [Detail]
    ️🔄CadlValidation inProgress [Detail]
    ️⌛PR Summary pending [Detail]
    Posted by Swagger Pipeline | How to fix these errors?

    @openapi-pipeline-app
    Copy link

    openapi-pipeline-app bot commented Nov 15, 2022

    Swagger Generation Artifacts

    ️⌛ApiDocPreview pending [Detail]
    ️⌛SDK Breaking Change Tracking pending [Detail]
    ️⌛ azure-sdk-for-net-track2 pending [Detail]
    ️⌛ azure-sdk-for-go pending [Detail]
    ️⌛ azure-sdk-for-python-track2 pending [Detail]
    ️⌛ azure-sdk-for-java pending [Detail]
    ️⌛ azure-sdk-for-js pending [Detail]
    Posted by Swagger Pipeline | How to fix these errors?

    @openapi-pipeline-app
    Copy link

    openapi-pipeline-app bot commented Nov 15, 2022

    Swagger pipeline restarted successfully. If there is ApiView generated, it will be updated in this comment.

    @openapi-workflow-bot
    Copy link

    Hi, @prchalla1, For review efficiency consideration, when creating a new api version, it is required to place API specs of the base version in the first commit, and push new version updates into successive commits. You can use OpenAPIHub to initialize the PR for adding a new version. For more details refer to the wiki. Or you could onboard API spec pipeline

    @openapi-workflow-bot
    Copy link

    Hi @prchalla1, Your PR has some issues. Please fix the CI sequentially by following the order of Avocado, semantic validation, model validation, breaking change, lintDiff. If you have any questions, please post your questions in this channel https://aka.ms/swaggersupport.

    TaskHow to fixPriority
    AvocadoFix-AvocadoHigh
    Semantic validationFix-SemanticValidation-ErrorHigh
    Model validationFix-ModelValidation-ErrorHigh
    LintDiffFix-LintDiffhigh
    If you need further help, please feedback via swagger feedback.

    @AzureRestAPISpecReview AzureRestAPISpecReview added the BreakingChangeReviewRequired <valid label in PR review process>add this label when breaking change review is required label Nov 15, 2022
    @openapi-workflow-bot
    Copy link

    Hi @prchalla1, one or multiple breaking change(s) is detected in your PR. Please check out the breaking change(s), and provide business justification in the PR comment and @ PR assignee why you must have these change(s), and how external customer impact can be mitigated. Please ensure to follow breaking change policy to request breaking change review and approval before proceeding swagger PR review.
    Action: To initiate an evaluation of the breaking change, create a new intake using the template for breaking changes. Addition details on the process and office hours are on the Breaking change Wiki.
    If you want to know the production traffic statistic, please see ARM Traffic statistic.
    If you think it is false positive breaking change, please provide the reasons in the PR comment, report to Swagger Tooling Team via https://aka.ms/swaggerfeedback.
    Note: To avoid breaking change, you can refer to Shift Left Solution for detecting breaking change in early phase at your service code repository.

    @azure-pipelines
    Copy link

    Azure Pipelines successfully started running 1 pipeline(s).

    @openapi-workflow-bot openapi-workflow-bot bot added the WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required label Dec 16, 2022
    @jayati-tehri
    Copy link
    Member

    Regarding the GUID usage, We receive MeterId in guid format from downstreams. The type is string but it’s a GUID and we are returning as is in response.

    Discussed with @zizw123 offline

    "200": {
    "description": "OK. The request has succeeded.",
    "schema": {
    "$ref": "#/definitions/PriceSheetResult"
    Copy link

    Choose a reason for hiding this comment

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

    PriceSheetResult

    This is listing API but the response is not in array form? Looks like in your example, the response is in array form

    Copy link
    Member

    Choose a reason for hiding this comment

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

    image

    The response property pricesheets items are array.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    Good point. When you implement a LIST api, ARM expects you to return an object with a 'value' property that holds the actual array of resources/objects.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    But... this isn't actually a LIST api, in the resource sense - in terms of the request path, its just a singleton get, i.e. fetching ONE pricesheet named default.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    And that resource just happens to contain a list....

    Copy link
    Member

    Choose a reason for hiding this comment

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

    I am unclear why its this way and its not a normal ARM LIST api, actually.

    Copy link
    Member

    Choose a reason for hiding this comment

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

    Agreed. I can take it up with my team to understand more on this, but we cannot change a response model without letting clients know right? They will have dependency on existing model. What do you suggest?
    This response model is same for all other versions of this API

    Copy link
    Member

    Choose a reason for hiding this comment

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

    @TimLovellSmith Can you please help on how should we proceed forward with this?

    Copy link
    Member

    Choose a reason for hiding this comment

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

    @jayati-tehri The answers to this depends on how you want to model this API overall :

    For example the API
    GET /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default

    Currently this is modelled as a single point GET of a subscription level pricesheet resource called default. Which means it should return only one resource and should not have nextlink. If you want to model this as a list instead to list all the individual pricesheets in the subscription then the call needs to be like this :

    GET /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/

    and this returns the list of various pricesheets in the subscription in the array format with next link.

    Also there is an issue with how you have created the response for a list operation , the nextlink should not be inside properties , check the output of the operationsList.json where you have modelled this correctly. This is explained in the microsoft REST guidelines here : https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#collections

    You should also go over that document in entirety to model these apis correctly.

    Please fix these APIs and let us know , if you need any further clarifications , please feel free to send me and the apireviews an email

    @openapi-workflow-bot openapi-workflow-bot bot removed the WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required label Dec 16, 2022
    @openapi-workflow-bot openapi-workflow-bot bot added the WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required label Dec 20, 2022
    @openapi-workflow-bot openapi-workflow-bot bot removed the WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required label Dec 20, 2022
    @openapi-workflow-bot openapi-workflow-bot bot added the WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required label Jan 3, 2023
    @mentat9
    Copy link
    Member

    mentat9 commented Jan 4, 2023

    @prchalla1 - I don't see a response to this comment: #21560 (comment). This is important: please let us know. I'll summarize the issue here:

    Currently you are using a singleton "default" instance of the pricesheets resource type to return all pricesheets. Since you are wrapping the array into an object, it doesn't technically break the RPC, but it basically says that a pricesheet is a list of pricesheets, which is not a good model. Plus, if you want to stick with that model, you still need to add the list endpoint for listing all pricesheets in order to follow the RPC. This would be on this endpoint: /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets, and would return a list of one item (named "default").

    I agree with @TimLovellSmith and @raosuhas that this should be modeled as a list API.

    @openapi-workflow-bot openapi-workflow-bot bot removed the WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required label Jan 4, 2023
    @prchalla1
    Copy link
    Contributor Author

    @prchalla1 - I don't see a response to this comment: #21560 (comment). This is important: please let us know. I'll summarize the issue here:

    Currently you are using a singleton "default" instance of the pricesheets resource type to return all pricesheets. Since you are wrapping the array into an object, it doesn't technically break the RPC, but it basically says that a pricesheet is a list of pricesheets, which is not a good model. Plus, if you want to stick with that model, you still need to add the list endpoint for listing all pricesheets in order to follow the RPC. This would be on this endpoint: /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets, and would return a list of one item (named "default").

    I agree with @TimLovellSmith and @raosuhas that this should be modeled as a list API.

    @jayati-tehri Can you look over this and reply on this comment.

    @openapi-pipeline-app
    Copy link

    openapi-pipeline-app bot commented Jan 5, 2023

    Swagger Validation Report

    ️️✔️BreakingChange succeeded [Detail] [Expand]
    There are no breaking changes.
    ️⚠️Breaking Change(Cross-Version): 1 Warnings warning [Detail]
    Rule Message
    ⚠️ APIsBeingMovedToANewSpec "details":"Attention: There are some existing APIs currently documented in a new spec file. The validation may not be able to report breaking changes with these APIs. It is recommended not to rename swagger file or move public APIs to a new file when creating a new API version.The existing APIs being moved are:Operations_List;",
    "location":"https://github.com/Azure/azure-rest-api-specs/blob/main/specification/consumption/resource-manager/Microsoft.Consumption/stable/2022-06-01/consumption.operations.pricesheet.json"
    ️️✔️CredScan succeeded [Detail] [Expand]
    There is no credential detected.
    ️❌LintDiff: 2 Errors, 0 Warnings failed [Detail]
    compared tags (via openapi-validator v2.0.0) new version base version
    package-2022-06 package-2022-06(d82db1d) default(main)

    [must fix]The following errors/warnings are introduced by current PR:

    Rule Message Related RPC [For API reviewers]
    TopLevelResourcesListBySubscription The top-level resource 'PriceSheetResult' does not have list by subscription operation, please add it.
    Location: Microsoft.Consumption/stable/2022-06-01/consumption.operations.pricesheet.json#L207
    RPC-Get-V1-05
    GuidUsage Usage of Guid is not recommended. If GUIDs are absolutely required in your service, please get sign off from the Azure API review board.
    Location: Microsoft.Consumption/stable/2022-06-01/consumption.operations.pricesheet.json#L280
    ️⚠️Avocado: 1 Warnings warning [Detail]
    Rule Message
    ⚠️ MULTIPLE_API_VERSION The default tag contains multiple API versions swaggers.
    readme: specification/consumption/resource-manager/readme.md
    tag: specification/consumption/resource-manager/readme.md#tag-package-2022-06
    ️️✔️ApiReadinessCheck succeeded [Detail] [Expand]
    ️⚠️~[Staging] ServiceAPIReadinessTest: 0 Warnings warning [Detail]

    API Test is not triggered due to precheck failure. Check pipeline log for details.

    ️️✔️~[Staging] SwaggerAPIView succeeded [Detail] [Expand]
    ️️✔️ModelValidation succeeded [Detail] [Expand]
    Validation passes for ModelValidation.
    ️️✔️SemanticValidation succeeded [Detail] [Expand]
    Validation passes for SemanticValidation.
    ️️✔️PoliCheck succeeded [Detail] [Expand]
    Validation passed for PoliCheck.
    ️️✔️PrettierCheck succeeded [Detail] [Expand]
    Validation passes for PrettierCheck.
    ️️✔️SpellCheck succeeded [Detail] [Expand]
    Validation passes for SpellCheck.
    ️️✔️Lint(RPaaS) succeeded [Detail] [Expand]
    Validation passes for Lint(RPaaS).
    ️️✔️CadlValidation succeeded [Detail] [Expand]
    Validation passes for CadlValidation.
    ️️✔️PR Summary succeeded [Detail] [Expand]
    Validation passes for Summary.
    Posted by Swagger Pipeline | How to fix these errors?

    @jayati-tehri
    Copy link
    Member

    @prchalla1 - I don't see a response to this comment: #21560 (comment). This is important: please let us know. I'll summarize the issue here:

    Currently you are using a singleton "default" instance of the pricesheets resource type to return all pricesheets. Since you are wrapping the array into an object, it doesn't technically break the RPC, but it basically says that a pricesheet is a list of pricesheets, which is not a good model. Plus, if you want to stick with that model, you still need to add the list endpoint for listing all pricesheets in order to follow the RPC. This would be on this endpoint: /subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets, and would return a list of one item (named "default").

    I agree with @TimLovellSmith and @raosuhas that this should be modeled as a list API.

    In the previous versions(refer :

    "/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default": {
    ), we have the same API route and our customers are using it, so if we can change the route or response, we will break existing customers.

    In this PR, we are just adding a new version for pricesheets and operations API.

    @mentat9
    Copy link
    Member

    mentat9 commented Jan 6, 2023

    @jayati-tehri, @prchalla1 - This is one reason it is critical that new API PRs follow this format:

    Adding a new API version
    -[ ] To review changes efficiently, ensure you copy the existing version into the new directory structure for first commit and then push new changes, including version updates, in separate commits. You can use OpenAPIHub to initialize the PR for adding a new version. For more details refer to the wiki.

    I don't know the full history of this PR/review, but it looks like previous reviewers didn't realize that this was not a newly added path. We put the above requirement on new API PRs so reviewers don't waste time re-reviewing APIs that have already shipped (among other reasons). As it stands now, it looks like there was also refactoring done in the middle, so I'm finding it really hard to determine what's new and what's previously shipped, even when I go back and compare with what's checked in under 2021-10-01.

    Can you make a new PR that follows the above requirement, so we can see what's getting changed? Copy everything from 2021-10-01 [unchanged] to the new version folder, make a commit, then apply changes for the new API version. If you want to refactor, it's best to do that in a separate PR afterward that doesn't change the APIs. The current feedback thread won't apply any more if the API in question isn't being added in the new API version.

    Note: improve the API doesn't require breaking customers: you can add the new correct list API without changing the existing one, then deprecate the old one according to the Azure retirement requirements (if you want).

    @jayati-tehri
    Copy link
    Member

    @mentat9
    Hi Chris,

    The reason we didn’t copy the previous folder into the new version 2022-06-01 is because we are introducing 2022-06-01 only for pricesheets and operations and rest other APIs route to 2021-10-01.
    In order to do so I have created a new file consumption.operations.pricesheet.json and added the Pricesheets and Operations API under it. In readme file I have two of the input files, one from the new version and other from the previous version(as shown below)

    We have done this for other APIs in the past when we wanted to introduce a version only for specific set of APIs. Please let me know if this doesn’t look correct.

    @mentat9
    Copy link
    Member

    mentat9 commented Jan 9, 2023

    @mentat9 Hi Chris,

    The reason we didn’t copy the previous folder into the new version 2022-06-01 is because we are introducing 2022-06-01 only for pricesheets and operations and rest other APIs route to 2021-10-01. In order to do so I have created a new file consumption.operations.pricesheet.json and added the Pricesheets and Operations API under it. In readme file I have two of the input files, one from the new version and other from the previous version(as shown below)

    We have done this for other APIs in the past when we wanted to introduce a version only for specific set of APIs. Please let me know if this doesn’t look correct.

    Thanks Jayati. The problem is that reviewers can't tell if it's correct (or what you are changing). The new file in the PR implies to reviewers that those are new APIs, but they aren't (or some aren't) as we just discovered. Since they moved to a new file, it's hard to tell how (or whether) they're different in the new API version, or that they aren't being added. It would help if you did the refactoring separately from the API changes. IOW, if you need to refactor to enable your release strategy, make those changes first (without any API changes), and add the new API version changes afterward. Something more like this:

    1. Start with currently released spec at stable\2021-10-01
    2. Copy consumption.json (and any examples you are reusing) to [new folder] stable\2022-06-01 unchanged
    3. Make an initial commit
    4. Move the existing APIs from consumption.json to the new file without changing the API version (2021-10-01).
    5. Make another commit as the base before API changes
    6. Apply additional edits and commits for the new API version (delete consumption.json, update version, add new APIs, add new examples, etc).
    7. Provide comments to reviewers indicating what you did

    This allows reviewers to see what's changing in the commit history. It's not perfect but combined with explanatory comments we can see/diff what is being modified w.r.t. the current API version and what is being added.

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

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    9 participants