-
Notifications
You must be signed in to change notification settings - Fork 46
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: @methodLocation decorator #914
Comments
I see the need for this decorator, what about something like |
similar with #493? |
main.tsp interface foo { client.tsp @clientName("FooClientOptions", "csharp") @@client(foo, { additionalInitialization: myClientInitModel }) //typegraph from tcgc SdkOperation { SdkMethod { |
To determine whether to map a method parameter onto the client parameter, we will
// main.tsp
namespace My.Service;
op upload(blobName: string): void;
op download(blobName: string): void;
op theName(bName: string): void;
// client.tsp
import "@azure-tools/typespec-client-generator-core";
using Azure.ClientGenerator.Core;
namespace My.Customizations;
model ClientInitOptions {
blobClientName: string;
}
@@clientInitialization(MyService, ClientInitOptions)
@@paramMap(download.blobName, ClientInitOptions.blobClientName);
@@paramMap(theName.bName, ClientInitOptions.blobClientName) |
How about the following scenario?
In view of up cons, I think it is better to adopt
I think up API could meet all kinds of scenario usage. For convenient client, it is easy to implement with base client like:
TCGC may need additional design for language emitters to map wrapped API with original generated API. |
General design in Java is to avoid having 2 (functionally same) API in different client. e.g. It does not appear in its parent e.g. PS: |
i also not prefer to have two same api in different client. i think only when all operations under a sub-client all have the same common parameter (kind of resource and sub resource) that we could make this parameter to be client level, and we should add lint for the new decorator to avoid other cases. |
I feel like I don't want to provide two methods with the same functionality in Modular either. In JS RLC, we will not take client.tsp method location customization, but we have a proposal for path parameter specifically in a more general way, because it's not very easy or have a good way to support this in a regular RLC experience Azure/autorest.typescript#2148 (comment), though it was just an initial thought and we haven't figured out any implementation details yet. // for path "/path1/{path1Param}/path2/{path2Param}", we have the following two ways to call the apis.
client.path("/path1/{path1Param}", path1ParamValue)
.path("/path2/{path2Param}", path2ParamValue)
client.path("/path1/{path1Param}/path2/{path2Param}", path1ParamValue, path2ParamValue).get();
// If there's another path "/path1/{path1Param}/path3/{path3Param}"
client.path("/path1/{path1Param}", path1ParamValue)
.path("/path3/{path3Param}", path3ParamValue)
client.path("/path1/{path1Param}/path3/{path3Param}", path1ParamValue, path3ParamValue).get(); In this way, if customer wants to save their effort of input path1Param in each method, they could take this approach. const subClient = client.path("/path1/{path1Param}", path1ParamValue);
subClient.path("/path2/{path2Param}", path2ParamValue)
subClient.path("/path3/{path3Param}", path3ParamValue) Another point of this approach is, mgmt plane path is very long path, which could benefit from this new user experience. |
@msyyc I think the decision to have the |
.NET in general will not two clients with the same api, too. But I think it is not required that all the operations in the client have the parameter then this parameter can be bumped to client level. Whether bump a parameter to client level is decided by archboard and service team according to the SDK usage/API definition. It may be good that |
fixes #914 --------- Co-authored-by: iscai-msft <isabellavcai@gmail.com>
fixes Azure#914 --------- Co-authored-by: iscai-msft <isabellavcai@gmail.com>
Is it possible to move parameters that persist on each operation to the client instead with a decorator of some sort? In EventGrid this shows up in the case of
client()
publish(topic_name, events)
receive(topic_name, subscription_name, max_events)
ack(topic_name, subscription_name, lock_tokens)
to
client(topic_name, subscription_name)
publish(events)
receive(max_events)
ack(lock_tokens)
typespec spec: https://github.com/Azure/azure-rest-api-specs/blob/9df71d5a717e4ed5e6728e7e6ba2fead60f62243/specification/eventgrid/Azure.Messaging.EventGrid/main.tsp#L261
The text was updated successfully, but these errors were encountered: