-
Notifications
You must be signed in to change notification settings - Fork 45
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
[tcgc] design for Java emitter to influence the default access property of SdkInitializationType and SdkClientAccessor #1702
Comments
i think currently, client accessor method is always set with |
I'm not fully understanding how TCGC isn't setting the correct access: are you talking about in the |
What I mean is that today (I am aware that TCGC didn't give full information at this time, so emitter of different language kind of handling this client-subclient in their own best practice), .NET and Python is actually generate the code according to the E.g. .NET Face API Python Face API All of above is done without service ever add It is only Java generating code as This is before we allow service to explicitly set the After support of optional Hence now we need TCGC always gives correct information. |
Upon #1696
Context
In TCGC, I take
SdkInitializationType.access
means whether the client/subclient is directly initializable (from builder or client class ctor).SdkClientAccessor.access
means whether the subclient can be accessed by this client access method (from parent client of this subclient).SdkInitializationType.model.access
means whether the model of theSdkInitializationType
is public or not.In Java, there is currently 2 pattern when accessing a subclient.
I assume it maps to TCGC
I assume it maps to TCGC
At present, DPG and unbranded by default uses "client builder pattern". And we also need certain configure to switch to "client accessor pattern" for some modules (e.g. Azure Face API, unbranded OpenAI)
And currently the TCGC value of
SdkInitializationType.access
andSdkClientAccessor.access
is not what Java expected. Therefore, Java emitter does not use the TCGC value for now.It would infer the client/subclient from whether the client has parent client.
PS: Java emitter would still treat the
SdkInitializationType.model.access
as "internal" or "none", as Java uses its properties directly and not the model (meaning there is currently no##ClientOptions
class for Java).With "access" in
@clientInitialization
Afterward, Java emitter must always use the TCGC value, as it cannot tell whether service has overridden the default
@clientInitialization
's "access" value.Problem to solve
Java emitter would still want to affect TCGC to provide the expect default value (when service did not set the "access"). And this default is different from other languages.
The intention is to avoid existing DPG from TypeSpec always adding mulitple lines of
@clientInitialization(<interface>, access=public, scope="java")
, to makesubclient.initialization.access=public
for Java.Possible solutions
Java emitter may provide a e.g.
defaultClientInitializationAccess
as TCGC context.Default
internal
for all languages, so that without client.tsp override, subclient is not directly initializable (without its parent client).And Java may provide
public
to TCGC context, for the required situations. <-- I assume it also switch theSdkClientAccessor.access
tointernal
on its parent client accessor methodThe text was updated successfully, but these errors were encountered: