Skip to content
2 changes: 1 addition & 1 deletion packages/typespec-ts/src/utils/clientUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function getModularClientOptions(
) {
const [hierarchy, client] = clientMap;
const clientOptions: ModularClientOptions = {
rlcClientName: `${client.name.replace("Client", "")}Context`
rlcClientName: `${client.name.replace(/Client$/, "")}Context`
Comment thread
MaryGao marked this conversation as resolved.
};
clientOptions.subfolder = hierarchy.join("/");
return clientOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { assert } from "chai";
import ClientLocationClientFactory, {
ClientLocationClient
} from "./generated/azure/client-generator-core/client-location/src/index.js";

describe("Azure Client Generator Core Client Location", () => {
let client: ClientLocationClient;

beforeEach(() => {
client = ClientLocationClientFactory({
allowInsecureConnection: true
});
});

describe("Move to Existing Sub Client", () => {
it("should get user", async () => {
const response = await client
.path("/azure/client-generator-core/client-location/user")
.get();

assert.strictEqual(response.status, "204");
});

it("should delete user", async () => {
const response = await client
.path("/azure/client-generator-core/client-location/user")
.delete();

assert.strictEqual(response.status, "204");
});

it("should get admin info", async () => {
const response = await client
.path("/azure/client-generator-core/client-location/admin")
.get();

assert.strictEqual(response.status, "204");
});
});

describe("Move to New Sub Client", () => {
it("should list products", async () => {
const response = await client
.path("/azure/client-generator-core/client-location/products")
.get();

assert.strictEqual(response.status, "204");
});

it("should archive product", async () => {
const response = await client
.path("/azure/client-generator-core/client-location/products/archive")
.post();

assert.strictEqual(response.status, "204");
});
});

describe("Move to Root Client", () => {
it("should get resource", async () => {
const response = await client
.path("/azure/client-generator-core/client-location/resource")
.get();

assert.strictEqual(response.status, "204");
});

it("should get health status", async () => {
const response = await client
.path("/azure/client-generator-core/client-location/health")
.get();

assert.strictEqual(response.status, "204");
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
!/src
/src/**
!/src/index.d.ts
!/.gitignore
!/tspconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import type { Client } from '@azure-rest/core-client';
import type { ClientOptions } from '@azure-rest/core-client';
import type { HttpResponse } from '@azure-rest/core-client';
import type { RequestParameters } from '@azure-rest/core-client';
import type { StreamableMethod } from '@azure-rest/core-client';

export declare interface ArchiveProduct {
post(options?: ArchiveProductParameters): StreamableMethod<ArchiveProduct204Response>;
}

export declare interface ArchiveProduct204Response extends HttpResponse {
status: "204";
}

export declare type ArchiveProductParameters = RequestParameters;

export declare type ClientLocationClient = Client & {
path: Routes;
};

export declare interface ClientLocationClientOptions extends ClientOptions {
}

declare function createClient(options?: ClientLocationClientOptions): ClientLocationClient;
export default createClient;

export declare interface DeleteUser204Response extends HttpResponse {
status: "204";
}

export declare type DeleteUserParameters = RequestParameters;

export declare interface GetAdminInfo {
get(options?: GetAdminInfoParameters): StreamableMethod<GetAdminInfo204Response>;
}

export declare interface GetAdminInfo204Response extends HttpResponse {
status: "204";
}

export declare type GetAdminInfoParameters = RequestParameters;

export declare interface GetHealthStatus {
get(options?: GetHealthStatusParameters): StreamableMethod<GetHealthStatus204Response>;
}

export declare interface GetHealthStatus204Response extends HttpResponse {
status: "204";
}

export declare type GetHealthStatusParameters = RequestParameters;

export declare interface GetResource {
get(options?: GetResourceParameters): StreamableMethod<GetResource204Response>;
}

export declare interface GetResource204Response extends HttpResponse {
status: "204";
}

export declare type GetResourceParameters = RequestParameters;

export declare interface GetUser {
get(options?: GetUserParameters): StreamableMethod<GetUser204Response>;
delete(options?: DeleteUserParameters): StreamableMethod<DeleteUser204Response>;
}

export declare interface GetUser204Response extends HttpResponse {
status: "204";
}

export declare type GetUserParameters = RequestParameters;

export declare interface ListProducts {
get(options?: ListProductsParameters): StreamableMethod<ListProducts204Response>;
}

export declare interface ListProducts204Response extends HttpResponse {
status: "204";
}

export declare type ListProductsParameters = RequestParameters;

export declare interface Routes {
(path: "/azure/client-generator-core/client-location/admin"): GetAdminInfo;
(path: "/azure/client-generator-core/client-location/user"): GetUser;
(path: "/azure/client-generator-core/client-location/products"): ListProducts;
(path: "/azure/client-generator-core/client-location/products/archive"): ArchiveProduct;
(path: "/azure/client-generator-core/client-location/resource"): GetResource;
(path: "/azure/client-generator-core/client-location/health"): GetHealthStatus;
}

export { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
emit:
- "@azure-tools/typespec-ts"
options:
"@azure-tools/typespec-ts":
emitter-output-dir: "{project-root}"
add-credentials: false
azure-sdk-for-js: false
package-details:
name: "@azure/client-generator-core-location"
version: "1.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ClientLocationClient } from "./generated/azure/client-generator-core/client-location/src/index.js";

describe("Azure ClientGeneratorCore Client Location", () => {
let client: ClientLocationClient;

beforeEach(() => {
client = new ClientLocationClient({
endpoint: "http://localhost:3002",
allowInsecureConnection: true
});
});

describe("Move to Existing Sub Client", () => {
it("should get user via userOperations", async () => {
await client.moveToExistingSubClient.userOperations.getUser();
});

it("should delete user via adminOperations", async () => {
await client.moveToExistingSubClient.adminOperations.deleteUser();
});

it("should get admin info via adminOperations", async () => {
await client.moveToExistingSubClient.adminOperations.getAdminInfo();
});
});

describe("Move to New Sub Client", () => {
it("should list products via productOperations", async () => {
await client.moveToNewSubClient.productOperations.listProducts();
});

it("should archive product via archiveOperations", async () => {
await client.archiveOperations.archiveProduct();
});
});

describe("Move to Root Client", () => {
it("should get resource via resourceOperations", async () => {
await client.moveToRootClient.resourceOperations.getResource();
});

it("should get health status on root client", async () => {
await client.getHealthStatus();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
!/src
/src/**
!/src/index.d.ts
!/.gitignore
!/tspconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { ClientOptions } from '@azure-rest/core-client';
import { OperationOptions } from '@azure-rest/core-client';
import { Pipeline } from '@azure/core-rest-pipeline';

export declare interface ArchiveOperationsArchiveProductOptionalParams extends OperationOptions {
}

export declare interface ArchiveOperationsOperations {
archiveProduct: (options?: ArchiveOperationsArchiveProductOptionalParams) => Promise<void>;
}

export declare class ClientLocationClient {
private _client;
readonly pipeline: Pipeline;
constructor(options?: ClientLocationClientOptionalParams);
getHealthStatus(options?: GetHealthStatusOptionalParams): Promise<void>;
readonly archiveOperations: ArchiveOperationsOperations;
readonly moveToRootClient: MoveToRootClientOperations;
readonly moveToNewSubClient: MoveToNewSubClientOperations;
readonly moveToExistingSubClient: MoveToExistingSubClientOperations;
}

export declare interface ClientLocationClientOptionalParams extends ClientOptions {
}

export declare interface GetHealthStatusOptionalParams extends OperationOptions {
}

export declare interface MoveToExistingSubClientAdminOperationsDeleteUserOptionalParams extends OperationOptions {
}

export declare interface MoveToExistingSubClientAdminOperationsGetAdminInfoOptionalParams extends OperationOptions {
}

export declare interface MoveToExistingSubClientAdminOperationsOperations {
deleteUser: (options?: MoveToExistingSubClientAdminOperationsDeleteUserOptionalParams) => Promise<void>;
getAdminInfo: (options?: MoveToExistingSubClientAdminOperationsGetAdminInfoOptionalParams) => Promise<void>;
}

export declare interface MoveToExistingSubClientOperations {
userOperations: MoveToExistingSubClientUserOperationsOperations;
adminOperations: MoveToExistingSubClientAdminOperationsOperations;
}

export declare interface MoveToExistingSubClientUserOperationsGetUserOptionalParams extends OperationOptions {
}

export declare interface MoveToExistingSubClientUserOperationsOperations {
getUser: (options?: MoveToExistingSubClientUserOperationsGetUserOptionalParams) => Promise<void>;
}

export declare interface MoveToNewSubClientOperations {
productOperations: MoveToNewSubClientProductOperationsOperations;
}

export declare interface MoveToNewSubClientProductOperationsListProductsOptionalParams extends OperationOptions {
}

export declare interface MoveToNewSubClientProductOperationsOperations {
listProducts: (options?: MoveToNewSubClientProductOperationsListProductsOptionalParams) => Promise<void>;
}

export declare interface MoveToRootClientOperations {
resourceOperations: MoveToRootClientResourceOperationsOperations;
}

export declare interface MoveToRootClientResourceOperationsGetResourceOptionalParams extends OperationOptions {
}

export declare interface MoveToRootClientResourceOperationsOperations {
getResource: (options?: MoveToRootClientResourceOperationsGetResourceOptionalParams) => Promise<void>;
}

export { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
emit:
- "@azure-tools/typespec-ts"
options:
"@azure-tools/typespec-ts":
emitter-output-dir: "{project-root}"
add-credentials: false
azure-sdk-for-js: false
is-modular-library: true
package-details:
name: "@azure/client-generator-core-location"
8 changes: 8 additions & 0 deletions packages/typespec-ts/test/commands/cadl-ranch-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ export const azureRlcTsps = [
{
outputPath: "azure/client-generator-core/deserialize-empty-string-as-null",
inputPath: "azure/client-generator-core/deserialize-empty-string-as-null"
},
{
outputPath: "azure/client-generator-core/client-location",
inputPath: "azure/client-generator-core/client-location"
}
];

Expand Down Expand Up @@ -847,6 +851,10 @@ export const azureModularTsps = [
{
outputPath: "azure/client-generator-core/deserialize-empty-string-as-null",
inputPath: "azure/client-generator-core/deserialize-empty-string-as-null"
},
{
outputPath: "azure/client-generator-core/client-location",
inputPath: "azure/client-generator-core/client-location"
}
];

Expand Down
Loading