Skip to content

Commit c80ba7d

Browse files
author
SDKAuto
committed
CodeGen from PR 16317 in Azure/azure-rest-api-specs
Merge 792b4c2a5db2857bb9ba1f1b78a1eb55e774fc99 into 49526d1a30dc4ba2f77e172c54c4ef7d8f53a8d1
1 parent bedb5a1 commit c80ba7d

21 files changed

+3872
-0
lines changed

sdk/agrifood/arm-agrifood/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Microsoft
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

sdk/agrifood/arm-agrifood/README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## Azure AzureAgriFoodRPService SDK for JavaScript
2+
3+
This package contains an isomorphic SDK (runs both in node.js and in browsers) for AzureAgriFoodRPService.
4+
5+
### Currently supported environments
6+
7+
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
8+
- Latest versions of Safari, Chrome, Edge and Firefox.
9+
10+
### Prerequisites
11+
12+
You must have an [Azure subscription](https://azure.microsoft.com/free/).
13+
14+
### How to install
15+
16+
To use this SDK in your project, you will need to install two packages.
17+
- `@azure/arm-agrifood` that contains the client.
18+
- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory.
19+
20+
Install both packages using the below command:
21+
```bash
22+
npm install --save @azure/arm-agrifood @azure/identity
23+
```
24+
> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features.
25+
If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options.
26+
27+
### How to use
28+
29+
- If you are writing a client side browser application,
30+
- Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions.
31+
- Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below.
32+
- If you are writing a server side application,
33+
- [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples)
34+
- Complete the set up steps required by the credential if any.
35+
- Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below.
36+
37+
In the below samples, we pass the credential and the Azure subscription id to instantiate the client.
38+
Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started.
39+
#### nodejs - Authentication, client creation, and get extensions as an example written in JavaScript.
40+
41+
##### Sample code
42+
43+
```javascript
44+
const { DefaultAzureCredential } = require("@azure/identity");
45+
const { AzureAgriFoodRPService } = require("@azure/arm-agrifood");
46+
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
47+
48+
// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples
49+
// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead.
50+
const creds = new DefaultAzureCredential();
51+
const client = new AzureAgriFoodRPService(creds, subscriptionId);
52+
const extensionId = "testextensionId";
53+
const farmBeatsResourceName = "testfarmBeatsResourceName";
54+
const resourceGroupName = "testresourceGroupName";
55+
client.extensions.get(extensionId, farmBeatsResourceName, resourceGroupName).then((result) => {
56+
console.log("The result is:");
57+
console.log(result);
58+
}).catch((err) => {
59+
console.log("An error occurred:");
60+
console.error(err);
61+
});
62+
```
63+
64+
#### browser - Authentication, client creation, and get extensions as an example written in JavaScript.
65+
66+
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
67+
- See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser.
68+
- Note down the client Id from the previous step and use it in the browser sample below.
69+
70+
##### Sample code
71+
72+
- index.html
73+
74+
```html
75+
<!DOCTYPE html>
76+
<html lang="en">
77+
<head>
78+
<title>@azure/arm-agrifood sample</title>
79+
<script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script>
80+
<script src="node_modules/@azure/identity/dist/index.js"></script>
81+
<script src="node_modules/@azure/arm-agrifood/dist/arm-agrifood.js"></script>
82+
<script type="text/javascript">
83+
const subscriptionId = "<Subscription_Id>";
84+
// Create credentials using the `@azure/identity` package.
85+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
86+
const credential = new InteractiveBrowserCredential(
87+
{
88+
clientId: "<client id for your Azure AD app>",
89+
tenant: "<optional tenant for your organization>"
90+
});
91+
const client = new Azure.ArmAgrifood.AzureAgriFoodRPService(creds, subscriptionId);
92+
const extensionId = "testextensionId";
93+
const farmBeatsResourceName = "testfarmBeatsResourceName";
94+
const resourceGroupName = "testresourceGroupName";
95+
client.extensions.get(extensionId, farmBeatsResourceName, resourceGroupName).then((result) => {
96+
console.log("The result is:");
97+
console.log(result);
98+
}).catch((err) => {
99+
console.log("An error occurred:");
100+
console.error(err);
101+
});
102+
</script>
103+
</head>
104+
<body></body>
105+
</html>
106+
```
107+
108+
## Related projects
109+
110+
- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)
111+
112+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/agrifood/arm-agrifood/README.png)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "@azure/arm-agrifood",
3+
"author": "Microsoft Corporation",
4+
"description": "AzureAgriFoodRPService Library with typescript type definitions for node.js and browser.",
5+
"version": "1.0.0",
6+
"dependencies": {
7+
"@azure/ms-rest-azure-js": "^2.1.0",
8+
"@azure/ms-rest-js": "^2.2.0",
9+
"@azure/core-auth": "^1.1.4",
10+
"tslib": "^1.10.0"
11+
},
12+
"keywords": [
13+
"node",
14+
"azure",
15+
"typescript",
16+
"browser",
17+
"isomorphic"
18+
],
19+
"license": "MIT",
20+
"main": "./dist/arm-agrifood.js",
21+
"module": "./esm/azureAgriFoodRPService.js",
22+
"types": "./esm/azureAgriFoodRPService.d.ts",
23+
"devDependencies": {
24+
"typescript": "^3.6.0",
25+
"rollup": "^1.18.0",
26+
"rollup-plugin-node-resolve": "^5.2.0",
27+
"rollup-plugin-sourcemaps": "^0.4.2",
28+
"uglify-js": "^3.6.0"
29+
},
30+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/agrifood/arm-agrifood",
31+
"repository": {
32+
"type": "git",
33+
"url": "https://github.com/Azure/azure-sdk-for-js.git"
34+
},
35+
"bugs": {
36+
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
37+
},
38+
"files": [
39+
"dist/**/*.js",
40+
"dist/**/*.js.map",
41+
"dist/**/*.d.ts",
42+
"dist/**/*.d.ts.map",
43+
"esm/**/*.js",
44+
"esm/**/*.js.map",
45+
"esm/**/*.d.ts",
46+
"esm/**/*.d.ts.map",
47+
"src/**/*.ts",
48+
"README.md",
49+
"rollup.config.js",
50+
"tsconfig.json"
51+
],
52+
"scripts": {
53+
"build": "tsc && rollup -c rollup.config.js && npm run minify",
54+
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/arm-agrifood.js.map'\" -o ./dist/arm-agrifood.min.js ./dist/arm-agrifood.js",
55+
"prepack": "npm install && npm run build"
56+
},
57+
"sideEffects": false,
58+
"autoPublish": true
59+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import rollup from "rollup";
2+
import nodeResolve from "rollup-plugin-node-resolve";
3+
import sourcemaps from "rollup-plugin-sourcemaps";
4+
5+
/**
6+
* @type {rollup.RollupFileOptions}
7+
*/
8+
const config = {
9+
input: "./esm/azureAgriFoodRPService.js",
10+
external: [
11+
"@azure/ms-rest-js",
12+
"@azure/ms-rest-azure-js"
13+
],
14+
output: {
15+
file: "./dist/arm-agrifood.js",
16+
format: "umd",
17+
name: "Azure.ArmAgrifood",
18+
sourcemap: true,
19+
globals: {
20+
"@azure/ms-rest-js": "msRest",
21+
"@azure/ms-rest-azure-js": "msRestAzure"
22+
},
23+
banner: `/*
24+
* Copyright (c) Microsoft Corporation.
25+
* Licensed under the MIT License.
26+
*
27+
* Code generated by Microsoft (R) AutoRest Code Generator.
28+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
29+
*/`
30+
},
31+
plugins: [
32+
nodeResolve({ mainFields: ['module', 'main'] }),
33+
sourcemaps()
34+
]
35+
};
36+
37+
export default config;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is
7+
* regenerated.
8+
*/
9+
10+
import * as msRest from "@azure/ms-rest-js";
11+
import { TokenCredential } from "@azure/core-auth";
12+
import * as Models from "./models";
13+
import * as Mappers from "./models/mappers";
14+
import * as operations from "./operations";
15+
import { AzureAgriFoodRPServiceContext } from "./azureAgriFoodRPServiceContext";
16+
17+
18+
class AzureAgriFoodRPService extends AzureAgriFoodRPServiceContext {
19+
// Operation groups
20+
extensions: operations.Extensions;
21+
farmBeatsExtensions: operations.FarmBeatsExtensions;
22+
farmBeatsModels: operations.FarmBeatsModels;
23+
locations: operations.Locations;
24+
operations: operations.Operations;
25+
26+
/**
27+
* Initializes a new instance of the AzureAgriFoodRPService class.
28+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
29+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
30+
* more information about these credentials, see
31+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
32+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
33+
* @azure/ms-rest-browserauth are also supported.
34+
* @param subscriptionId The ID of the target subscription.
35+
* @param [options] The parameter options
36+
*/
37+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureAgriFoodRPServiceOptions) {
38+
super(credentials, subscriptionId, options);
39+
this.extensions = new operations.Extensions(this);
40+
this.farmBeatsExtensions = new operations.FarmBeatsExtensions(this);
41+
this.farmBeatsModels = new operations.FarmBeatsModels(this);
42+
this.locations = new operations.Locations(this);
43+
this.operations = new operations.Operations(this);
44+
}
45+
}
46+
47+
// Operation Specifications
48+
49+
export {
50+
AzureAgriFoodRPService,
51+
AzureAgriFoodRPServiceContext,
52+
Models as AzureAgriFoodRPServiceModels,
53+
Mappers as AzureAgriFoodRPServiceMappers
54+
};
55+
export * from "./operations";
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is
7+
* regenerated.
8+
*/
9+
10+
import * as Models from "./models";
11+
import * as msRest from "@azure/ms-rest-js";
12+
import * as msRestAzure from "@azure/ms-rest-azure-js";
13+
import { TokenCredential } from "@azure/core-auth";
14+
15+
const packageName = "@azure/arm-agrifood";
16+
const packageVersion = "1.0.0";
17+
18+
export class AzureAgriFoodRPServiceContext extends msRestAzure.AzureServiceClient {
19+
credentials: msRest.ServiceClientCredentials | TokenCredential;
20+
apiVersion?: string;
21+
subscriptionId: string;
22+
23+
/**
24+
* Initializes a new instance of the AzureAgriFoodRPService class.
25+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
26+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
27+
* more information about these credentials, see
28+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
29+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
30+
* @azure/ms-rest-browserauth are also supported.
31+
* @param subscriptionId The ID of the target subscription.
32+
* @param [options] The parameter options
33+
*/
34+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureAgriFoodRPServiceOptions) {
35+
if (credentials == undefined) {
36+
throw new Error('\'credentials\' cannot be null.');
37+
}
38+
if (subscriptionId == undefined) {
39+
throw new Error('\'subscriptionId\' cannot be null.');
40+
}
41+
42+
if (!options) {
43+
options = {};
44+
}
45+
if (!options.userAgent) {
46+
const defaultUserAgent = msRestAzure.getDefaultUserAgentValue();
47+
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
48+
}
49+
50+
super(credentials, options);
51+
52+
this.apiVersion = '2020-05-12-preview';
53+
this.acceptLanguage = 'en-US';
54+
this.longRunningOperationRetryTimeout = 30;
55+
this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com";
56+
this.requestContentType = "application/json; charset=utf-8";
57+
this.credentials = credentials;
58+
this.subscriptionId = subscriptionId;
59+
60+
if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
61+
this.acceptLanguage = options.acceptLanguage;
62+
}
63+
if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) {
64+
this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout;
65+
}
66+
}
67+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
export {
10+
AzureEntityResource,
11+
BaseResource,
12+
DetailedInformation,
13+
ErrorAdditionalInfo,
14+
ErrorDetail,
15+
ErrorResponse,
16+
Extension,
17+
ExtensionListResponse,
18+
FarmBeats,
19+
FarmBeatsExtension,
20+
ProxyResource,
21+
Resource,
22+
SystemData,
23+
TrackedResource,
24+
UnitSystemsInfo
25+
} from "../models/mappers";

0 commit comments

Comments
 (0)