-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[agrifood] Update snippets generation (#32459)
### Packages impacted by this PR - @azure-rest/agrifood-farming - @azure/arm-agrifood ### Issues associated with this PR - #32416 ### Describe the problem that is addressed by this PR Updates the agrifood projects to use snippet extraction. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
- Loading branch information
1 parent
f322179
commit 814b725
Showing
11 changed files
with
153 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { describe, it } from "vitest"; | ||
import { FarmBeats, isUnexpected, paginate } from "@azure-rest/agrifood-farming"; | ||
import { DefaultAzureCredential } from "@azure/identity"; | ||
import { setLogLevel } from "@azure/logger"; | ||
|
||
describe("snippets", async () => { | ||
it("CreateFarmBeatsClient", async () => { | ||
const client = FarmBeats( | ||
"https://<farmbeats resource name>.farmbeats.azure.net", | ||
new DefaultAzureCredential(), | ||
); | ||
}); | ||
|
||
it("CreateParty", async () => { | ||
const client = FarmBeats( | ||
"https://<farmbeats resource name>.farmbeats.azure.net", | ||
new DefaultAzureCredential(), | ||
); | ||
// @ts-preserve-whitespace | ||
const partyId = "test_party"; | ||
const result = await client.path("/parties/{partyId}", partyId).patch({ | ||
body: { | ||
name: "Contoso Party", | ||
description: "Your custom party description here", | ||
status: "Active", | ||
properties: { foo: "bar", "numeric one": 1, "1": "numeric key" }, | ||
}, | ||
// Set the content-type of the request | ||
contentType: "application/merge-patch+json", | ||
}); | ||
// @ts-preserve-whitespace | ||
if (isUnexpected(result)) { | ||
throw result.body.error; | ||
} | ||
// @ts-preserve-whitespace | ||
const party = result.body; | ||
console.log(`Created Party: ${party.name}`); | ||
}); | ||
|
||
it("ListParties", async () => { | ||
const client = FarmBeats( | ||
"https://<farmbeats resource name>.farmbeats.azure.net", | ||
new DefaultAzureCredential(), | ||
); | ||
// @ts-preserve-whitespace | ||
const response = await client.path("/parties").get(); | ||
// @ts-preserve-whitespace | ||
if (isUnexpected(response)) { | ||
throw response.body.error; | ||
} | ||
// @ts-preserve-whitespace | ||
const parties = paginate(client, response); | ||
// @ts-preserve-whitespace | ||
// Log each party id | ||
for await (const party of parties) { | ||
const partyOutput = party; | ||
console.log(partyOutput.id); | ||
} | ||
}); | ||
|
||
it("SetLogLevel", async () => { | ||
setLogLevel("info"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{ | ||
"extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] | ||
"extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"], | ||
"compilerOptions": { | ||
"paths": { | ||
"@azure-rest/agrifood-farming": ["./src/index.ts"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.