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

Autorest Regen to update scope to include non-public clouds #39224

Merged
merged 19 commits into from
Mar 26, 2024

Conversation

jairmyree
Copy link
Member

@jairmyree jairmyree commented Mar 14, 2024

Closes #37002

I adjusted the swagger documentation to include the China and US Government clouds as part of the default scopes.

I also adjusted the code generation file to require fewer manual edits upon regeneration. As it is in my PR, you only need to revert the module-info with each regeneration.

@jairmyree jairmyree requested review from srnagar, lmolkova and a team as code owners March 14, 2024 19:53
@github-actions github-actions bot added the Monitor Monitor, Monitor Ingestion, Monitor Query label Mar 14, 2024
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@jairmyree jairmyree requested a review from srnagar March 15, 2024 20:05
// Licensed under the MIT License.

package com.azure.monitor.ingestion.models;

Copy link
Member

Choose a reason for hiding this comment

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

Add JavaDocs.


public class LogIngestionAudience {

private final String audience;
Copy link
Member

Choose a reason for hiding this comment

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

Align the names of the audience with other libraries - for e.g. DocumentAnalysisAudience

Comment on lines +7 to +8
The following edits need to be made manually after code generation:
- Rollback the edits to `module-info` file
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this is a DPG client, every time you regenerate from swagger it attempts to set the module-info as well. However, it does so incorrectly and will produce build errors if it's not corrected.

Copy link
Member Author

Choose a reason for hiding this comment

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

@srnagar After looking at the autorest documentation I didn't see a flag that would disable edits to the module-info.

Comment on lines 16 to 17
implementation-subpackage: ""
generate-client-as-impl: true
Copy link
Member

Choose a reason for hiding this comment

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

Why are these settings needed?

Copy link
Member Author

@jairmyree jairmyree Mar 26, 2024

Choose a reason for hiding this comment

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

Autorest by default will take anything that is to be non-public implementation and put it under a implementation sub-package. But since the namespace for this autorest generation is already com.azure.monitor.ingestion.implementation , we don't want com.azure.monitor.ingestion.implementation.implementation. So you need to specify where to put the implementation which in this case is at the root of the namespace.

Copy link
Member Author

Choose a reason for hiding this comment

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

"generate-client-as-impl" is unnecessary and I'll remove that one.

```yaml
java: true
use: '@autorest/java@4.1.9'
Copy link
Member

Choose a reason for hiding this comment

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

We should pin the autorest version that should be used for generating the library.

Copy link
Member Author

Choose a reason for hiding this comment

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

@srnagar I'll pin it to the latest, but can you tell me why we should do this? Autorest versions are not auto-updated like other dependencies and I've seen that a lot of other SDKs are using outdated autorest versions because nobody is keeping an eye on them.

Copy link
Member

Choose a reason for hiding this comment

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

This is because we don't want different devs using different autorest versions to regenerate. If a version is not specified, autorest will use the latest version available locally on the dev's machine which can lead to different code generated on different versions.

Comment on lines 29 to 35
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-monitor-ingestion</artifactId>
<version>1.2.0-beta.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Copy link
Member

Choose a reason for hiding this comment

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

Why is this dependency needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not. I'll remove it.


import java.util.function.Consumer;

public class MonitorIngestionCustomizations extends Customization {
Copy link
Member

Choose a reason for hiding this comment

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

Add javadoc to describe what customizations are being done here.

jairmyree and others added 4 commits March 25, 2024 17:20
…nitor/ingestion/models/LogIngestionAudience.java

Co-authored-by: Srikanta <51379715+srnagar@users.noreply.github.com>
…nitor/ingestion/models/LogIngestionAudience.java

Co-authored-by: Srikanta <51379715+srnagar@users.noreply.github.com>
…nitor/ingestion/models/LogIngestionAudience.java

Co-authored-by: Srikanta <51379715+srnagar@users.noreply.github.com>
@jairmyree jairmyree requested a review from srnagar March 26, 2024 17:15
```yaml
java: true
use: '@autorest/java@4.1.9'
Copy link
Member

Choose a reason for hiding this comment

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

This is because we don't want different devs using different autorest versions to regenerate. If a version is not specified, autorest will use the latest version available locally on the dev's machine which can lead to different code generated on different versions.

@jairmyree jairmyree requested a review from srnagar March 26, 2024 19:44
output-folder: ../
license-header: MICROSOFT_MIT_SMALL
input-file: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/monitor/data-plane/ingestion/stable/2023-01-01/DataCollectionRules.json
namespace: com.azure.monitor.ingestion.implementation
implementation-subpackage: ""
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

}

/**
* Customizes the generated code for `IngestionUsingDataCollectionRulesClientBuilder`.
Copy link
Member

Choose a reason for hiding this comment

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

Javadoc should describe the customization changes rather than just stating "Customizes "

import java.util.function.Consumer;

/**
* Customization class for Monitor. These customizations will be applied on top of the generated code.
Copy link
Member

Choose a reason for hiding this comment

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

The javadoc should include the details of what changes are being made.

@jairmyree jairmyree merged commit 10d323b into Azure:main Mar 26, 2024
18 checks passed
@jairmyree jairmyree deleted the update-scope-for-monitor-ingestion branch March 26, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monitor Monitor, Monitor Ingestion, Monitor Query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Azure Monitor Ingestion authZ scope
3 participants