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

multipart/form-data support for typespec-todo #2984

Merged
merged 10 commits into from
Jan 15, 2025
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function _getDataProducts(context: NetworkAnalyticsApiContext) {
};
}

export function getDataProductsOperations(
export function _getDataProductsOperations(
context: NetworkAnalyticsApiContext,
): DataProductsOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function _getDataProductsCatalogs(context: NetworkAnalyticsApiContext) {
};
}

export function getDataProductsCatalogsOperations(
export function _getDataProductsCatalogsOperations(
context: NetworkAnalyticsApiContext,
): DataProductsCatalogsOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function _getDataTypes(context: NetworkAnalyticsApiContext) {
};
}

export function getDataTypesOperations(
export function _getDataTypesOperations(
context: NetworkAnalyticsApiContext,
): DataTypesOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function _getOperations(context: NetworkAnalyticsApiContext) {
};
}

export function getOperationsOperations(
export function _getOperationsOperations(
context: NetworkAnalyticsApiContext,
): OperationsOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// Licensed under the MIT License.

import {
getDataProductsOperations,
_getDataProductsOperations,
DataProductsOperations,
} from "./classic/dataProducts/index.js";
import {
getDataTypesOperations,
_getDataTypesOperations,
DataTypesOperations,
} from "./classic/dataTypes/index.js";
import {
getDataProductsCatalogsOperations,
_getDataProductsCatalogsOperations,
DataProductsCatalogsOperations,
} from "./classic/dataProductsCatalogs/index.js";
import {
getOperationsOperations,
_getOperationsOperations,
OperationsOperations,
} from "./classic/operations/index.js";
import {
Expand Down Expand Up @@ -46,10 +46,12 @@ export class NetworkAnalyticsApi {
userAgentOptions: { userAgentPrefix },
});
this.pipeline = this._client.pipeline;
this.dataProducts = getDataProductsOperations(this._client);
this.dataTypes = getDataTypesOperations(this._client);
this.dataProductsCatalogs = getDataProductsCatalogsOperations(this._client);
this.operations = getOperationsOperations(this._client);
this.dataProducts = _getDataProductsOperations(this._client);
this.dataTypes = _getDataTypesOperations(this._client);
this.dataProductsCatalogs = _getDataProductsCatalogsOperations(
this._client,
);
this.operations = _getOperationsOperations(this._client);
}

/** The operation groups for dataProducts */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@ export interface FileContentResponse {
content: Uint8Array;
}

// @public
export type FileContents = string | NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array | Blob;
Copy link
Member

Choose a reason for hiding this comment

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

just curious why this is added? is this expected?

Copy link
Member Author

@timovv timovv Jan 13, 2025

Choose a reason for hiding this comment

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

Seems like this spec has an anonymous model for MFD which isn't properly supported yet. FileContents should be used in uploadFile but is currently Uint8Array. Will fix.

Copy link
Member Author

@timovv timovv Jan 14, 2025

Choose a reason for hiding this comment

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

Will address anonymous models including this case in a follow up issue


// @public
export interface FileDeletionStatus {
deleted: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Licensed under the MIT License.

import {
getEvaluationsOperations,
_getEvaluationsOperations,
EvaluationsOperations,
} from "./classic/evaluations/index.js";
import {
getConnectionsOperations,
_getConnectionsOperations,
ConnectionsOperations,
} from "./classic/connections/index.js";
import {
getAgentsOperations,
_getAgentsOperations,
AgentsOperations,
} from "./classic/agents/index.js";
import {
Expand Down Expand Up @@ -49,9 +49,9 @@ export class AzureAIClient {
{ ...options, userAgentOptions: { userAgentPrefix } },
);
this.pipeline = this._client.pipeline;
this.evaluations = getEvaluationsOperations(this._client);
this.connections = getConnectionsOperations(this._client);
this.agents = getAgentsOperations(this._client);
this.evaluations = _getEvaluationsOperations(this._client);
this.connections = _getConnectionsOperations(this._client);
this.agents = _getAgentsOperations(this._client);
}

/** The operation groups for evaluations */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ function _getAgents(context: AzureAIContext) {
};
}

export function getAgentsOperations(context: AzureAIContext): AgentsOperations {
export function _getAgentsOperations(
context: AzureAIContext,
): AgentsOperations {
return {
..._getAgents(context),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function _getConnections(context: AzureAIContext) {
};
}

export function getConnectionsOperations(
export function _getConnectionsOperations(
context: AzureAIContext,
): ConnectionsOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function _getEvaluations(context: AzureAIContext) {
};
}

export function getEvaluationsOperations(
export function _getEvaluationsOperations(
context: AzureAIContext,
): EvaluationsOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { FileContents } from "./static-helpers/multipartHelpers.js";
import {
PageSettings,
ContinuablePage,
Expand Down Expand Up @@ -276,3 +277,4 @@ export {
EvaluationsOperations,
} from "./classic/index.js";
export { PageSettings, ContinuablePage, PagedAsyncIterableIterator };
export { FileContents };
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/**
* Valid values for the contents of a binary file.
*/
export type FileContents =
| string
| NodeJS.ReadableStream
| ReadableStream<Uint8Array>
| Uint8Array
| Blob;

export function createFilePartDescriptor(
partName: string,
fileInput: any,
defaultContentType?: string,
): any {
if (fileInput.contents) {
return {
name: partName,
body: fileInput.contents,
contentType: fileInput.contentType ?? defaultContentType,
filename: fileInput.filename,
};
} else {
return {
name: partName,
body: fileInput,
contentType: defaultContentType,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT License.

import {
getMultivariateOperations,
_getMultivariateOperations,
MultivariateOperations,
} from "./classic/multivariate/index.js";
import {
getUnivariateOperations,
_getUnivariateOperations,
UnivariateOperations,
} from "./classic/univariate/index.js";
import {
Expand Down Expand Up @@ -56,8 +56,8 @@ export class AnomalyDetectorClient {
userAgentOptions: { userAgentPrefix },
});
this.pipeline = this._client.pipeline;
this.multivariate = getMultivariateOperations(this._client);
this.univariate = getUnivariateOperations(this._client);
this.multivariate = _getMultivariateOperations(this._client);
this.univariate = _getUnivariateOperations(this._client);
}

/** The operation groups for multivariate */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function _getMultivariate(context: AnomalyDetectorContext) {
};
}

export function getMultivariateOperations(
export function _getMultivariateOperations(
context: AnomalyDetectorContext,
): MultivariateOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function _getUnivariate(context: AnomalyDetectorContext) {
};
}

export function getUnivariateOperations(
export function _getUnivariateOperations(
context: AnomalyDetectorContext,
): UnivariateOperations {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function _getBC(context: FooContext) {
};
}

export function getBCOperations(context: FooContext): BCOperations {
export function _getBCOperations(context: FooContext): BCOperations {
return {
..._getBC(context),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function _getBEC(context: FooContext) {
};
}

export function getBECOperations(context: FooContext): BECOperations {
export function _getBECOperations(context: FooContext): BECOperations {
return {
..._getBEC(context),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Licensed under the MIT License.

import { FooContext } from "../../../api/fooContext.js";
import { BECOperations, getBECOperations } from "./c/index.js";
import { BECOperations, _getBECOperations } from "./c/index.js";

/** Interface representing a BE operations. */
export interface BEOperations {
c: BECOperations;
}

export function getBEOperations(context: FooContext): BEOperations {
export function _getBEOperations(context: FooContext): BEOperations {
return {
c: getBECOperations(context),
c: _getBECOperations(context),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { FooContext } from "../../api/fooContext.js";
import { op1 } from "../../api/b/index.js";
import { Ba } from "../../models/b/models.js";
import { BOp1OptionalParams } from "../../api/options.js";
import { BCOperations, getBCOperations } from "./c/index.js";
import { BEOperations, getBEOperations } from "./e/index.js";
import { BCOperations, _getBCOperations } from "./c/index.js";
import { BEOperations, _getBEOperations } from "./e/index.js";

/** Interface representing a B operations. */
export interface BOperations {
Expand All @@ -22,10 +22,10 @@ function _getB(context: FooContext) {
};
}

export function getBOperations(context: FooContext): BOperations {
export function _getBOperations(context: FooContext): BOperations {
return {
..._getB(context),
c: getBCOperations(context),
e: getBEOperations(context),
c: _getBCOperations(context),
e: _getBEOperations(context),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function _getD(context: FooContext) {
};
}

export function getDOperations(context: FooContext): DOperations {
export function _getDOperations(context: FooContext): DOperations {
return {
..._getD(context),
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { getDOperations, DOperations } from "./classic/d/index.js";
import { getBOperations, BOperations } from "./classic/b/index.js";
import { _getDOperations, DOperations } from "./classic/d/index.js";
import { _getBOperations, BOperations } from "./classic/b/index.js";
import {
createFoo,
FooContext,
Expand Down Expand Up @@ -30,8 +30,8 @@ export class FooClient {
userAgentOptions: { userAgentPrefix },
});
this.pipeline = this._client.pipeline;
this.d = getDOperations(this._client);
this.b = getBOperations(this._client);
this.d = _getDOperations(this._client);
this.b = _getBOperations(this._client);
}

/** The operation groups for d */
Expand Down
Loading
Loading