Skip to content

Commit

Permalink
adopt the emitter changes on namespace (#5224)
Browse files Browse the repository at this point in the history
* format

* it is not working - it turns out we have to keep this namespace configuration

* update version

* regen

* fix ci

* fix the compilation issue in emitter

* fix format

* bump a version and see what would happen in regen

* regen

* update to official version
  • Loading branch information
ArcturusZhang authored Feb 7, 2025
1 parent 247f697 commit 0169675
Show file tree
Hide file tree
Showing 119 changed files with 1,784 additions and 1,819 deletions.
1,719 changes: 7 additions & 1,712 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions samples/AnomalyDetector/tspCodeModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Multivariate",
"doc": "The batch detection status.",
"isFixed": true,
"isFlags": false,
Expand Down Expand Up @@ -143,6 +144,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Multivariate",
"doc": "Data schema of input data source: OneTable or MultiTable. The default DataSchema is OneTable.",
"isFixed": false,
"isFlags": false,
Expand Down Expand Up @@ -197,6 +199,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Multivariate",
"doc": "The alignment mode.",
"isFixed": true,
"isFlags": false,
Expand Down Expand Up @@ -302,6 +305,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Multivariate",
"doc": "An optional field, indicating how missing values will be filled. One of Previous, Subsequent, Linear, Zero, Fixed.",
"isFixed": false,
"isFlags": false,
Expand Down Expand Up @@ -390,6 +394,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Multivariate",
"doc": "the model status.",
"isFixed": true,
"isFlags": false,
Expand Down Expand Up @@ -563,6 +568,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Univariate",
"doc": "the time granularity of the data points.",
"isFixed": true,
"isFlags": false,
Expand Down Expand Up @@ -685,6 +691,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Univariate",
"doc": "The impute mode.",
"isFixed": false,
"isFlags": false,
Expand Down Expand Up @@ -892,6 +899,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector.Univariate",
"isFixed": true,
"isFlags": false,
"usage": "Json,Exception",
Expand Down Expand Up @@ -928,6 +936,7 @@
"decorators": []
}
],
"clientNamespace": "AnomalyDetector",
"isFixed": true,
"isFlags": false,
"usage": "Input,ApiVersionEnum",
Expand All @@ -939,6 +948,7 @@
"$id": "108",
"kind": "model",
"name": "MultivariateDetectionResult",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateDetectionResult",
"usage": "Output,Json",
"doc": "Detection results for the given resultId.",
Expand Down Expand Up @@ -988,6 +998,7 @@
"$id": "115",
"kind": "model",
"name": "MultivariateBatchDetectionResultSummary",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateBatchDetectionResultSummary",
"usage": "Output,Json",
"doc": "Multivariate anomaly detection status.",
Expand Down Expand Up @@ -1030,6 +1041,7 @@
"$id": "121",
"kind": "model",
"name": "ErrorResponse",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ErrorResponse",
"usage": "Output,Error,Json,Exception",
"doc": "ErrorResponse contains code and message that shows the error information.",
Expand Down Expand Up @@ -1122,6 +1134,7 @@
"$id": "134",
"kind": "model",
"name": "VariableState",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.VariableState",
"usage": "Input,Output,Json",
"doc": "Variable Status.",
Expand Down Expand Up @@ -1307,6 +1320,7 @@
"$id": "160",
"kind": "model",
"name": "MultivariateBatchDetectionOptions",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateBatchDetectionOptions",
"usage": "Input,Output,Json",
"doc": "Detection request for batch inference. This is an asynchronous inference which\nwill need another API to get detection results.",
Expand Down Expand Up @@ -1482,6 +1496,7 @@
"$id": "185",
"kind": "model",
"name": "AnomalyState",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyState",
"usage": "Output,Json",
"doc": "Anomaly status and information.",
Expand Down Expand Up @@ -1532,6 +1547,7 @@
"$id": "192",
"kind": "model",
"name": "AnomalyValue",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyValue",
"usage": "Output,Json",
"doc": "Detailed information of the anomalous timestamp.",
Expand Down Expand Up @@ -1632,6 +1648,7 @@
"$id": "207",
"kind": "model",
"name": "AnomalyInterpretation",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyInterpretation",
"usage": "Output,Json",
"doc": "Interpretation of the anomalous timestamp.",
Expand Down Expand Up @@ -1701,6 +1718,7 @@
"$id": "217",
"kind": "model",
"name": "CorrelationChanges",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.CorrelationChanges",
"usage": "Output,Json",
"doc": "Correlation changes among the anomalous variables",
Expand Down Expand Up @@ -1870,6 +1888,7 @@
"$id": "235",
"kind": "model",
"name": "ModelInfo",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ModelInfo",
"usage": "Input,Output,Json",
"doc": "Training result of a model including its status, errors and diagnostics\ninformation.",
Expand Down Expand Up @@ -2059,6 +2078,7 @@
"$id": "262",
"kind": "model",
"name": "AlignPolicy",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AlignPolicy",
"usage": "Input,Output,Json",
"doc": "An optional field, indicating the manner to align multiple variables.",
Expand Down Expand Up @@ -2216,6 +2236,7 @@
"$id": "283",
"kind": "model",
"name": "DiagnosticsInfo",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.DiagnosticsInfo",
"usage": "Input,Output,Json",
"doc": "Diagnostics information to help inspect the states of model or variable.",
Expand All @@ -2231,6 +2252,7 @@
"$id": "285",
"kind": "model",
"name": "ModelState",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ModelState",
"usage": "Input,Output,Json",
"doc": "Model status.",
Expand Down Expand Up @@ -2449,6 +2471,7 @@
"$id": "314",
"kind": "model",
"name": "AnomalyDetectionModel",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyDetectionModel",
"usage": "Output,Json",
"doc": "Response of getting a model.",
Expand Down Expand Up @@ -2587,6 +2610,7 @@
"$id": "333",
"kind": "model",
"name": "ModelList",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ModelList",
"usage": "Output,Json",
"doc": "Response of listing models.",
Expand Down Expand Up @@ -2709,6 +2733,7 @@
"$id": "350",
"kind": "model",
"name": "MultivariateLastDetectionOptions",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateLastDetectionOptions",
"usage": "Input,Json",
"doc": "Request of last detection.",
Expand All @@ -2728,6 +2753,7 @@
"$id": "353",
"kind": "model",
"name": "VariableValues",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.VariableValues",
"usage": "Input,Json",
"doc": "Variable values.",
Expand Down Expand Up @@ -2883,6 +2909,7 @@
"$id": "374",
"kind": "model",
"name": "MultivariateLastDetectionResult",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateLastDetectionResult",
"usage": "Output,Json",
"doc": "Results of last detection.",
Expand Down Expand Up @@ -2954,6 +2981,7 @@
"$id": "383",
"kind": "model",
"name": "UnivariateDetectionOptions",
"clientNamespace": "AnomalyDetector.Univariate",
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateDetectionOptions",
"usage": "Input,Json",
"doc": "The request of entire or last anomaly detection.",
Expand All @@ -2973,6 +3001,7 @@
"$id": "386",
"kind": "model",
"name": "TimeSeriesPoint",
"clientNamespace": "AnomalyDetector.Univariate",
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.TimeSeriesPoint",
"usage": "Input,Json",
"doc": "The definition of input timeseries points.",
Expand Down Expand Up @@ -3249,6 +3278,7 @@
"$id": "424",
"kind": "model",
"name": "UnivariateEntireDetectionResult",
"clientNamespace": "AnomalyDetector.Univariate",
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateEntireDetectionResult",
"usage": "Output,Json",
"doc": "The response of entire anomaly detection.",
Expand Down Expand Up @@ -3525,6 +3555,7 @@
"$id": "464",
"kind": "model",
"name": "AnomalyDetectorError",
"clientNamespace": "AnomalyDetector.Univariate",
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.AnomalyDetectorError",
"usage": "Error,Json,Exception",
"doc": "Error information returned by the API.",
Expand Down Expand Up @@ -3586,6 +3617,7 @@
"$id": "472",
"kind": "model",
"name": "UnivariateLastDetectionResult",
"clientNamespace": "AnomalyDetector.Univariate",
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateLastDetectionResult",
"usage": "Output,Json",
"doc": "The response of last anomaly detection.",
Expand Down Expand Up @@ -3840,6 +3872,7 @@
"$id": "509",
"kind": "model",
"name": "UnivariateChangePointDetectionOptions",
"clientNamespace": "AnomalyDetector.Univariate",
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateChangePointDetectionOptions",
"usage": "Input,Json",
"doc": "The request of change point detection.",
Expand Down Expand Up @@ -4012,6 +4045,7 @@
"$id": "533",
"kind": "model",
"name": "UnivariateChangePointDetectionResult",
"clientNamespace": "AnomalyDetector.Univariate",
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateChangePointDetectionResult",
"usage": "Output,Json",
"doc": "The response of change point detection.",
Expand Down Expand Up @@ -4118,6 +4152,7 @@
"$id": "548",
"kind": "model",
"name": "ResponseError",
"clientNamespace": "AnomalyDetector.Multivariate",
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ResponseError",
"usage": "Error",
"doc": "Error response",
Expand Down Expand Up @@ -4176,6 +4211,7 @@
{
"$id": "555",
"Name": "AnomalyDetectorClient",
"ClientNamespace": "AnomalyDetector",
"Doc": "The Anomaly Detector API detects anomalies automatically in time series data.\nIt supports two kinds of mode, one is for stateless using, another is for\nstateful using. In stateless mode, there are three functionalities. Entire\nDetect is for detecting the whole series with model trained by the time series,\nLast Detect is detecting last point with model trained by points before.\nChangePoint Detect is for detecting trend changes in time series. In stateful\nmode, user can store time series, the stored time series will be used for\ndetection anomalies. Under this mode, user can still use the above three\nfunctionalities by only giving a time range without preparing time series in\nclient side. Besides the above three functionalities, stateful model also\nprovide group based detection and labeling service. By leveraging labeling\nservice user can provide labels for each detection result, these labels will be\nused for retuning or regenerating detection models. Inconsistency detection is\na kind of group based detection, this detection will find inconsistency ones in\na set of time series. By using anomaly detector service, business customers can\ndiscover incidents and establish a logic flow for root cause analysis.",
"Operations": [],
"Protocol": {
Expand Down Expand Up @@ -4237,6 +4273,7 @@
{
"$id": "562",
"Name": "Univariate",
"ClientNamespace": "AnomalyDetector.Univariate",
"Operations": [
{
"$id": "563",
Expand Down Expand Up @@ -21101,6 +21138,7 @@
{
"$id": "2922",
"Name": "Multivariate",
"ClientNamespace": "AnomalyDetector.Multivariate",
"Operations": [
{
"$id": "2923",
Expand Down
12 changes: 11 additions & 1 deletion src/AutoRest.CSharp/LowLevel/Output/LowLevelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public LowLevelClient(string name, string ns, string description, string library
{
_libraryName = libraryName;
_typeFactory = typeFactory;
DefaultName = name;
DefaultName = GetClientName(name);
Description = description;
IsSubClient = parentClient != null;
ParentClient = parentClient;
Expand All @@ -78,6 +78,16 @@ public LowLevelClient(string name, string ns, string description, string library
SubClients = Array.Empty<LowLevelClient>();
}

private static string GetClientName(string name)
{
if (Configuration.ModelNamespace && name == "Models")
{
// TODO -- we should report a warning diagnostic here indicating that we are changing something in the input.
return "ModelsOps"; // Avoid conflict with the Models namespace
}
return name;
}

private IReadOnlyList<Parameter>? _parameters;
public IReadOnlyList<Parameter> Parameters => _parameters ??= new RestClientBuilder(_clientParameters, _operations, _typeFactory).GetOrderedParametersByRequired();

Expand Down
2 changes: 1 addition & 1 deletion src/TypeSpec.Extension/Emitter.Csharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"dependencies": {
"@autorest/csharp": "3.0.0-beta.20240625.4",
"@typespec/http-client-csharp": "0.1.9-alpha.20250205.2"
"@typespec/http-client-csharp": "0.1.9-alpha.20250206.2"
},
"peerDependencies": {
"@azure-tools/typespec-azure-core": ">=0.50.0 <1.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/TypeSpec.Extension/Emitter.Csharp/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export async function $onEmit(context: EmitContext<AzureNetEmitterOptions>) {

configurations["enable-internal-raw-data"] =
options["enable-internal-raw-data"];
configurations["model-namespace"] = options["model-namespace"];
const examplesDir =
options["examples-dir"] ?? options["examples-directory"];
if (examplesDir) {
Expand Down
6 changes: 6 additions & 0 deletions src/TypeSpec.Extension/Emitter.Csharp/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { dllFilePath } from "@autorest/csharp";

export interface AzureNetEmitterOptions extends NetEmitterOptions {
csharpGeneratorPath?: string;
"model-namespace"?: boolean;
"enable-internal-raw-data"?: boolean;
"single-top-level-client"?: boolean;
"existing-project-folder"?: string;
Expand Down Expand Up @@ -40,6 +41,10 @@ export const AzureNetEmitterOptionsSchema: JSONSchemaType<AzureNetEmitterOptions
type: "boolean",
default: false
},
"model-namespace": {
type: "boolean",
nullable: true
},
"single-top-level-client": { type: "boolean", nullable: true },
"existing-project-folder": { type: "string", nullable: true },
"keep-non-overloadable-protocol-signature": {
Expand Down Expand Up @@ -112,6 +117,7 @@ export function resolveAzureEmitterOptions(
"enable-internal-raw-data":
context.options["enable-internal-raw-data"] ??
defaultAzureEmitterOptions["enable-internal-raw-data"],
"model-namespace": context.options["model-namespace"],
"models-to-treat-empty-string-as-null":
context.options["models-to-treat-empty-string-as-null"] ??
defaultAzureEmitterOptions["models-to-treat-empty-string-as-null"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"$id": "2",
"kind": "model",
"name": "InvalidAuth",
"clientNamespace": "Authentication.ApiKey",
"crossLanguageDefinitionId": "Authentication.ApiKey.InvalidAuth",
"usage": "Error,Json,Exception",
"decorators": [],
Expand Down Expand Up @@ -45,6 +46,7 @@
{
"$id": "7",
"Name": "ApiKeyClient",
"ClientNamespace": "Authentication.ApiKey",
"Doc": "Illustrates clients generated with ApiKey authentication.",
"Operations": [
{
Expand Down
Loading

0 comments on commit 0169675

Please sign in to comment.