Skip to content

Commit

Permalink
Use clients from azcore (#910)
Browse files Browse the repository at this point in the history
Generated clients now contain an internal client from azcore.
Removed client constructors for non-ARM targets.
Error on optional client parameters for ARM.
Exporting clients is now on by default.
  • Loading branch information
jhendrixMSFT authored Jan 18, 2023
1 parent 7e54f9a commit 6410712
Show file tree
Hide file tree
Showing 373 changed files with 7,472 additions and 9,689 deletions.
2 changes: 1 addition & 1 deletion src/autorest-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ help-content:
description: Optional prefix to file names. For example, if you set your file prefix to "zzz_", all generated code files will begin with "zzz_".
- key: export-clients
type: boolean
description: Indicates if generated clients are to be exported. Default to true for ARM, false for data-plane.
description: Indicates if generated clients are to be exported. Default is true.
- key: module-version
description: When --azure-arm is true, semantic version to include in generated telemetryInfo constant without the leading 'v' (e.g. 1.2.3).
type: string
Expand Down
2 changes: 1 addition & 1 deletion src/generator/gomod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { lt, toSemver } from '@azure-tools/codegen';
export async function generateGoModFile(session: Session<CodeModel>, existingGoMod: string): Promise<string> {
// here we specify the minimum version of azcore as required by the code generator.
// the version can be overwritten by passing the --azcore-version switch during generation.
const version = await session.getValue('azcore-version', '1.0.0');
const version = await session.getValue('azcore-version', '1.3.0');
if (!version.match(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9_.-]+)?$/)) {
throw new Error(`azcore version ${version} must in the format major.minor.patch[-beta.N]`);
}
Expand Down
269 changes: 48 additions & 221 deletions src/generator/operations.ts

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions src/transform/namer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export async function namer(session: Session<CodeModel>) {
model.language.go!.openApiType = specType;
const azureARM = await session.getValue('azure-arm', false);
model.language.go!.azureARM = azureARM;
const exportClients = await session.getValue('export-clients', false);
model.language.go!.exportClients = exportClients;
const headAsBoolean = await session.getValue('head-as-boolean', false);
model.language.go!.headAsBoolean = headAsBoolean;
const groupParameters = await session.getValue('group-parameters', true);
Expand Down Expand Up @@ -165,7 +163,6 @@ export async function namer(session: Session<CodeModel>) {
clientNames.add(group.language.go!.clientName);
}

const exportClient = session.model.language.go!.openApiType === 'arm' || exportClients;
// fix up stuttering client names and operation names
for (const group of values(model.operationGroups)) {
const groupDetails = <Language>group.language.go;
Expand All @@ -176,10 +173,6 @@ export async function namer(session: Session<CodeModel>) {
throw new Error(`client ${originalName} was renamed to ${groupDetails.clientName} which collides with an existing client name`);
}
groupDetails.clientCtorName = `New${groupDetails.clientName}`;
if (!exportClient) {
groupDetails.clientName = ensureNameCase(groupDetails.clientName, true);
groupDetails.clientCtorName = uncapitalize(groupDetails.clientCtorName);
}
for (const op of values(group.operations)) {
const details = <OperationNaming>op.language.go;
// propagate these settings to each operation for ease of access
Expand Down
4 changes: 2 additions & 2 deletions test/acr/2021-07-01/azacr/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module azacr

go 1.18

require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0
require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/text v0.3.7 // indirect
)
8 changes: 4 additions & 4 deletions test/acr/2021-07-01/azacr/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0 h1:VuHAcMq8pU1IWNT/m5yRaGqbK0BiQKHT8X4DTp9CHdI=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0/go.mod h1:tZoQYdDZNOiIjdSn0dVWVfl0NEPGOJqVLzSrcFk4Is0=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 h1:Oj853U9kG+RLTCQXpjvOnrv0WaZHxgmZz1TlLywgOPY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
Expand Down
50 changes: 20 additions & 30 deletions test/acr/2021-07-01/azacr/zz_authentication_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6410712

Please sign in to comment.