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

http-client-java, remove logics that uses raw_lro_meta_data #4741

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

haolingdong-msft
Copy link
Member

No description provided.

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Oct 15, 2024
@azure-sdk
Copy link
Collaborator

No changes needing a change description found.

export function modelIs(model: Model, name: string, namespace: string): boolean {
let currentModel: Model | undefined = model;
export function modelIs(model: SdkModelType | undefined, name: string, namespace: string): boolean {
// use raw model because SdkModelType does not have sourceModel information
Copy link
Member Author

@haolingdong-msft haolingdong-msft Oct 15, 2024

Choose a reason for hiding this comment

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

Currently I'm using raw model because SdkModelType does not have sourceModel information and this is by TCGC's design.

A more straightforward way is to use model.crossLanguageDefinitionId to do the comparison and not compare for source model. Code like below:

function modelIs(model: SdkModelType | undefined, crosslanguageDefinitionId: string) {
     return model.crosslanguageDefinitionId === crosslanguageDefinitionId;
}

But for model A is Azure.Core.Foundations.OperationStatus case, model A will be generated.

Copy link
Contributor

@weidongxu-microsoft weidongxu-microsoft Oct 16, 2024

Choose a reason for hiding this comment

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

Yeah, this logic handle the sourceModel too.

Wondering whether TCGC have similar function.

Copy link
Member Author

@haolingdong-msft haolingdong-msft Oct 17, 2024

Choose a reason for hiding this comment

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

No, TCGC does not have similar function. They said for model A is Azure.Core.Foundations.OperationStatus case, model A be generated is expected, because when using is definition, it is a different model. If we really want to no generate model A, we need to use raw. /cc @tadelesh

name: string | undefined,
namespace: string,
): boolean {
let currentOp: Operation | undefined = operation.__raw.operation;
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm also using the raw operation currently. Because SdkHttpOperation does not have name and namespace properties. But I checked the usages of operationIs function, it is only used to check if an operation is an azure core operation. So maybe we can have below helper function.

function operationIsInAzureCore(operation: SdkHttpOperation) {
  operation.crossLanguageDefinitionId.contains("Azure.Core");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The func checks sourceOperation too. I guess TCGC does not have this on operation yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's similar, TCGC does not this on operation.

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

@@ -217,8 +218,9 @@ export function getUnionDescription(union: Union, typeNameOptions: TypeNameOptio
return name;
}

export function modelIs(model: Model, name: string, namespace: string): boolean {
let currentModel: Model | undefined = model;
export function modelIs(model: SdkModelType | undefined, name: string, namespace: string): boolean {
Copy link
Contributor

@weidongxu-microsoft weidongxu-microsoft Oct 16, 2024

Choose a reason for hiding this comment

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

I don't think model=undefined case should be handled in this func.

It should be handled before getting into this (if no polling model, is it still an LRO?).
Not very sure about mgmt-plane, kind of remember it still have a polling model (but we probably didn't use).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:java Issue for the Java client emitter: @typespec/http-client-java
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants