@azure-rest/maps-geolocation 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 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.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # Azure Maps Geolocation REST client library for JavaScript
2
+
3
+ Azure Maps Geolocation Client
4
+
5
+ \*\*If you are not familiar with our REST client, please spend 5 minutes to take a look at our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library, the REST client provides a light-weighted & developer friendly way to call azure rest api
6
+
7
+ Key links:
8
+
9
+ - [Source code][source_code]
10
+ - [Package (NPM)][npm_package]
11
+ - [API reference documentation][api_ref]
12
+ - [Samples][samples]
13
+ - [Product Information][product_info]
14
+
15
+ ## Getting started
16
+
17
+ ### Currently supported environments
18
+
19
+ - [LTS versions of Node.js](https://nodejs.org/about/releases/)
20
+ - Latest versions of Safari, Chrome, Edge and Firefox.
21
+
22
+ ### Prerequisites
23
+
24
+ - You must have an [Azure subscription][az_subscription] to use this package.
25
+ - An [Azure Maps account][az_maps_account_management]. You can create the resource via the [Azure Portal][azure_portal], the [Azure PowerShell][azure_powershell], or the [Azure CLI][azure_cli].
26
+
27
+ If you use Azure CLI, replace `<resource-group-name>` and `<map-account-name>` of your choice, and select a proper [pricing tier][az_map_pricing] based on your needs via the `<sku-name>` parameter. Please refer to [Azure Maps Reference for Azure CLI][az_map_az_cli] for more details.
28
+
29
+ ```bash
30
+ az maps account create --resource-group <resource-group-name> --name <map-account-name> --sku <sku-name>
31
+ ```
32
+
33
+ ### Install the `@azure-rest/maps-geolocation` package
34
+
35
+ Install the Azure Maps Geolocation REST client REST client library for JavaScript with `npm`:
36
+
37
+ ```bash
38
+ npm install @azure-rest/maps-geolocation
39
+ ```
40
+
41
+ ### Create and authenticate a `MapsGeolocationClient`
42
+
43
+ You'll need a `credential` instance for authentication when creating the `MapsGeolocationClient` instance used to access the Azure Maps render APIs. You can use either an Azure Active Directory (Azure AD) credential or an Azure subscription key to authenticate. For more information on authentication, see [Authentication with Azure Maps][az_map_auth].
44
+
45
+ #### Using an Azure AD credential
46
+
47
+ To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
48
+ provide an instance of the desired credential type obtained from the
49
+ [@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
50
+
51
+ To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
52
+
53
+ After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
54
+ As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
55
+ can be used to authenticate the client.
56
+
57
+ You'll need to register the new Azure AD application and grant access to Azure Maps by assigning the required role to your service principal. For more information, see [Host a daemon on non-Azure resources](https://learn.microsoft.com/azure/azure-maps/how-to-secure-daemon-app#host-a-daemon-on-non-azure-resources). Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
58
+ `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
59
+
60
+ You will also need to specify the Azure Maps resource you intend to use by specifying the `clientId` in the client options.
61
+ The Azure Maps resource client id can be found in the Authentication sections in the Azure Maps resource. Please refer to the [documentation](https://docs.microsoft.com/azure/azure-maps/how-to-manage-authentication#view-authentication-details) on how to find it.
62
+
63
+ ```javascript
64
+ const MapsGeolocation = require("@azure-rest/maps-geolocation").default;
65
+ const { DefaultAzureCredential } = require("@azure/identity");
66
+ const credential = new DefaultAzureCredential();
67
+ const client = MapsGeolocation(credential, "<maps-account-client-id>");
68
+ ```
69
+
70
+ #### Using a Subscription Key Credential
71
+
72
+ You can authenticate with your Azure Maps Subscription Key. Please install the `@azure/core-auth` package:
73
+
74
+ ```bash
75
+ npm install @azure/core-auth
76
+ ```
77
+
78
+ ```javascript
79
+ const MapsGeolocation = require("@azure-rest/maps-geolocation").default;
80
+ const AzureKeyCredential = require("@azure/core-auth");
81
+ const credential = new AzureKeyCredential("<subscription-key>");
82
+ const client = MapsGeolocation(credential);
83
+ ```
84
+
85
+ ## Key concepts
86
+
87
+ ### MapsGeolocationClient
88
+
89
+ `MapsGeolocationClient` is the primary interface for developers using the Azure Maps Geolocation client library. Explore the methods on this client object to understand the different features of the Azure Maps Geolocation service that you can access.
90
+
91
+ ## Examples
92
+
93
+ You can get the country code from a IP address:
94
+
95
+ ```javascript
96
+ const isUnexpected = require("@azure-rest/maps-geolocation");
97
+
98
+ const result = await client.path("/geolocation/ip/{format}", "json").get({
99
+ queryParameters: { ip: "2001:4898:80e8:b::189" },
100
+ });
101
+
102
+ if (isUnexpected(result)) {
103
+ throw result.body.error;
104
+ }
105
+ if (!result.body.countryRegion) {
106
+ throw new Error("No country region was found for the IP address.");
107
+ }
108
+ console.log(`The country code for the IP address is ${result.body.countryRegion.isoCode}`);
109
+ ```
110
+
111
+ ## Troubleshooting
112
+
113
+ ### Logging
114
+
115
+ Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
116
+
117
+ ```javascript
118
+ const { setLogLevel } = require("@azure/logger");
119
+
120
+ setLogLevel("info");
121
+ ```
122
+
123
+ For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
124
+
125
+ ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fmaps%2Fmaps-geolocation-rest%2FREADME.png)
126
+
127
+ <!-- [source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-geolocation-rest -->
128
+ <!-- [npm_package]: https://www.npmjs.com/package/@azure-rest/maps-geolocation -->
129
+ <!-- [api_ref]: https://docs.microsoft.com/javascript/api/@azure-rest/maps-geolocation?view=azure-node-preview -->
130
+ <!-- [samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-geolocation-rest/samples -->
131
+
132
+ [product_info]: https://learn.microsoft.com/rest/api/maps/geolocation
133
+ [az_subscription]: https://azure.microsoft.com/free/
134
+ [az_maps_account_management]: https://docs.microsoft.com/azure/azure-maps/how-to-manage-account-keys
135
+ [azure_portal]: https://portal.azure.com
136
+ [azure_powershell]: https://docs.microsoft.com/powershell/module/az.maps/new-azmapsaccount
137
+ [azure_cli]: https://docs.microsoft.com/cli/azure
138
+ [az_map_pricing]: https://docs.microsoft.com/azure/azure-maps/choose-pricing-tier
139
+ [az_map_az_cli]: https://docs.microsoft.com/cli/azure/maps/account?view=azure-cli-latest#az_maps_account_create
140
+ [az_map_auth]: https://learn.microsoft.com/azure/azure-maps/azure-maps-authentication
package/dist/index.js ADDED
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var coreAuth = require('@azure/core-auth');
6
+ var mapsCommon = require('@azure/maps-common');
7
+ var coreClient = require('@azure-rest/core-client');
8
+ var coreRestPipeline = require('@azure/core-rest-pipeline');
9
+
10
+ // Copyright (c) Microsoft Corporation.
11
+ /**
12
+ * Initialize a new instance of the class MapsGeolocationClient class.
13
+ * @param credentials type: KeyCredential
14
+ */
15
+ function createClient(credentials, options = {}) {
16
+ var _a, _b;
17
+ const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `https://atlas.microsoft.com`;
18
+ options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "1.0";
19
+ options = Object.assign(Object.assign({}, options), { credentials: {
20
+ apiKeyHeaderName: "subscription-key"
21
+ } });
22
+ const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;
23
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
24
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
25
+ : `${userAgentInfo}`;
26
+ options = Object.assign(Object.assign({}, options), { userAgentOptions: {
27
+ userAgentPrefix
28
+ } });
29
+ const client = coreClient.getClient(baseUrl, credentials, options);
30
+ return client;
31
+ }
32
+
33
+ // Copyright (c) Microsoft Corporation.
34
+ // Licensed under the MIT license.
35
+ const responseMap = {
36
+ "GET /geolocation/ip/{format}": ["200"]
37
+ };
38
+ function isUnexpected(response) {
39
+ const lroOriginal = response.headers["x-ms-original-url"];
40
+ const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
41
+ const method = response.request.method;
42
+ let pathDetails = responseMap[`${method} ${url.pathname}`];
43
+ if (!pathDetails) {
44
+ pathDetails = geParametrizedPathSuccess(method, url.pathname);
45
+ }
46
+ return !pathDetails.includes(response.status);
47
+ }
48
+ function geParametrizedPathSuccess(method, path) {
49
+ var _a, _b;
50
+ const pathParts = path.split("/");
51
+ // Iterate the responseMap to find a match
52
+ for (const [key, value] of Object.entries(responseMap)) {
53
+ // Extracting the path from the map key which is in format
54
+ // GET /path/foo
55
+ if (!key.startsWith(method)) {
56
+ continue;
57
+ }
58
+ const candidatePath = getPathFromMapKey(key);
59
+ // Get each part of the url path
60
+ const candidateParts = candidatePath.split("/");
61
+ // If the candidate and actual paths don't match in size
62
+ // we move on to the next candidate path
63
+ if (candidateParts.length === pathParts.length &&
64
+ hasParametrizedPath(key)) {
65
+ // track if we have found a match to return the values found.
66
+ let found = true;
67
+ for (let i = 0; i < candidateParts.length; i++) {
68
+ if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) &&
69
+ ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.endsWith("}"))) {
70
+ // If the current part of the candidate is a "template" part
71
+ // it is a match with the actual path part on hand
72
+ // skip as the parameterized part can match anything
73
+ continue;
74
+ }
75
+ // If the candidate part is not a template and
76
+ // the parts don't match mark the candidate as not found
77
+ // to move on with the next candidate path.
78
+ if (candidateParts[i] !== pathParts[i]) {
79
+ found = false;
80
+ break;
81
+ }
82
+ }
83
+ // We finished evaluating the current candidate parts
84
+ // if all parts matched we return the success values form
85
+ // the path mapping.
86
+ if (found) {
87
+ return value;
88
+ }
89
+ }
90
+ }
91
+ // No match was found, return an empty array.
92
+ return [];
93
+ }
94
+ function hasParametrizedPath(path) {
95
+ return path.includes("/{");
96
+ }
97
+ function getPathFromMapKey(mapKey) {
98
+ const pathStart = mapKey.indexOf("/");
99
+ return mapKey.slice(pathStart);
100
+ }
101
+
102
+ // Copyright (c) Microsoft Corporation.
103
+ function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {}) {
104
+ const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
105
+ /**
106
+ * maps service requires a header "ms-x-client-id", which is different from the standard AAD.
107
+ * So we need to do our own implementation.
108
+ * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication
109
+ */
110
+ if (coreAuth.isTokenCredential(credential)) {
111
+ const clientId = typeof clientIdOrOptions === "string" ? clientIdOrOptions : "";
112
+ if (!clientId) {
113
+ throw Error("Client id is needed for TokenCredential");
114
+ }
115
+ const client = createClient(undefined, options);
116
+ client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
117
+ credential,
118
+ scopes: `${options.baseUrl || "https://atlas.microsoft.com"}/.default`,
119
+ }));
120
+ client.pipeline.addPolicy(mapsCommon.createMapsClientIdPolicy(clientId));
121
+ return client;
122
+ }
123
+ return createClient(credential, options);
124
+ }
125
+
126
+ // Copyright (c) Microsoft Corporation.
127
+
128
+ exports["default"] = MapsGeolocation;
129
+ exports.isUnexpected = isUnexpected;
130
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/generated/mapsGeolocationClient.ts","../src/generated/isUnexpected.ts","../src/MapsGeolocation.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsGeolocationClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of the class MapsGeolocationClient class.\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n credentials: KeyCredential,\n options: ClientOptions = {}\n): MapsGeolocationClient {\n const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;\n options.apiVersion = options.apiVersion ?? \"1.0\";\n options = {\n ...options,\n credentials: {\n apiKeyHeaderName: \"subscription-key\"\n }\n };\n\n const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix\n }\n };\n\n const client = getClient(\n baseUrl,\n credentials,\n options\n ) as MapsGeolocationClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n GeolocationGetLocation200Response,\n GeolocationGetLocationDefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /geolocation/ip/{format}\": [\"200\"]\n};\n\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse;\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (\n candidateParts.length === pathParts.length &&\n hasParametrizedPath(key)\n ) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.endsWith(\"}\")\n ) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\nimport { AzureKeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport { MapsGeolocationClient } from \"./generated\";\nimport createClient from \"./generated\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsGeolocation(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureKeyCredential,\n options?: ClientOptions\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts\n * import MapsGeolocation from \"@azure/maps-geo-location\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsGeolocation(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsGeolocation(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions\n): MapsGeolocationClient;\nexport default function MapsGeolocation(\n credential: TokenCredential | AzureKeyCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {}\n): MapsGeolocationClient {\n const options = typeof clientIdOrOptions === \"string\" ? maybeOptions : clientIdOrOptions;\n\n /**\n * maps service requires a header \"ms-x-client-id\", which is different from the standard AAD.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: `${options.baseUrl || \"https://atlas.microsoft.com\"}/.default`,\n })\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n return createClient(credential, options);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsGeolocation from \"./MapsGeolocation\";\n\nexport * from \"./generated\";\nexport default MapsGeolocation;\n"],"names":["getClient","isTokenCredential","bearerTokenAuthenticationPolicy","createMapsClientIdPolicy"],"mappings":";;;;;;;;;AAAA;AAOA;;;AAGG;AACqB,SAAA,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE,EAAA;;IAE3B,MAAM,OAAO,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,6BAA6B,CAAC;IACjE,OAAO,CAAC,UAAU,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,UAAU,MAAI,IAAA,IAA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C,gDAA+B,CAAC;YAC9B,UAAU;AACV,YAAA,MAAM,EAAE,CAAG,EAAA,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAW,SAAA,CAAA;AACvE,SAAA,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAACC,mCAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9D,QAAA,OAAO,MAAM,CAAC;AACf,KAAA;AACD,IAAA,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C;;AC9EA;;;;;"}
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { isTokenCredential } from "@azure/core-auth";
4
+ import { createMapsClientIdPolicy } from "@azure/maps-common";
5
+ import createClient from "./generated";
6
+ import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
7
+ export default function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {}) {
8
+ const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
9
+ /**
10
+ * maps service requires a header "ms-x-client-id", which is different from the standard AAD.
11
+ * So we need to do our own implementation.
12
+ * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication
13
+ */
14
+ if (isTokenCredential(credential)) {
15
+ const clientId = typeof clientIdOrOptions === "string" ? clientIdOrOptions : "";
16
+ if (!clientId) {
17
+ throw Error("Client id is needed for TokenCredential");
18
+ }
19
+ const client = createClient(undefined, options);
20
+ client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({
21
+ credential,
22
+ scopes: `${options.baseUrl || "https://atlas.microsoft.com"}/.default`,
23
+ }));
24
+ client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));
25
+ return client;
26
+ }
27
+ return createClient(credential, options);
28
+ }
29
+ //# sourceMappingURL=MapsGeolocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAuC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA0C5E,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAgD,EAChD,oBAA4C,EAAE,EAC9C,eAA8B,EAAE;IAEhC,MAAM,OAAO,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEzF;;;;OAIG;IACH,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,QAAQ,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;SACxD;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,+BAA+B,CAAC;YAC9B,UAAU;YACV,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,WAAW;SACvE,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;KACf;IACD,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\nimport { AzureKeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport { MapsGeolocationClient } from \"./generated\";\nimport createClient from \"./generated\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsGeolocation(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureKeyCredential,\n options?: ClientOptions\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts\n * import MapsGeolocation from \"@azure/maps-geo-location\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsGeolocation(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsGeolocation(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions\n): MapsGeolocationClient;\nexport default function MapsGeolocation(\n credential: TokenCredential | AzureKeyCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {}\n): MapsGeolocationClient {\n const options = typeof clientIdOrOptions === \"string\" ? maybeOptions : clientIdOrOptions;\n\n /**\n * maps service requires a header \"ms-x-client-id\", which is different from the standard AAD.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: `${options.baseUrl || \"https://atlas.microsoft.com\"}/.default`,\n })\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n return createClient(credential, options);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=clientDefinitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../../src/generated/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { GeolocationGetLocationParameters } from \"./parameters\";\nimport {\n GeolocationGetLocation200Response,\n GeolocationGetLocationDefaultResponse\n} from \"./responses\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface GetLocation {\n /**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.\n */\n get(\n options: GeolocationGetLocationParameters\n ): StreamableMethod<\n GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse\n >;\n}\n\nexport interface Routes {\n /** Resource for '/geolocation/ip/\\{format\\}' has methods for the following verbs: get */\n (path: \"/geolocation/ip/{format}\", format: \"json\"): GetLocation;\n}\n\nexport type MapsGeolocationClient = Client & {\n path: Routes;\n};\n"]}
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import MapsGeolocationClient from "./mapsGeolocationClient";
4
+ export * from "./mapsGeolocationClient";
5
+ export * from "./parameters";
6
+ export * from "./responses";
7
+ export * from "./clientDefinitions";
8
+ export * from "./isUnexpected";
9
+ export * from "./outputModels";
10
+ export default MapsGeolocationClient;
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generated/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsGeolocationClient from \"./mapsGeolocationClient\";\n\nexport * from \"./mapsGeolocationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./outputModels\";\n\nexport default MapsGeolocationClient;\n"]}
@@ -0,0 +1,69 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ const responseMap = {
4
+ "GET /geolocation/ip/{format}": ["200"]
5
+ };
6
+ export function isUnexpected(response) {
7
+ const lroOriginal = response.headers["x-ms-original-url"];
8
+ const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
9
+ const method = response.request.method;
10
+ let pathDetails = responseMap[`${method} ${url.pathname}`];
11
+ if (!pathDetails) {
12
+ pathDetails = geParametrizedPathSuccess(method, url.pathname);
13
+ }
14
+ return !pathDetails.includes(response.status);
15
+ }
16
+ function geParametrizedPathSuccess(method, path) {
17
+ var _a, _b;
18
+ const pathParts = path.split("/");
19
+ // Iterate the responseMap to find a match
20
+ for (const [key, value] of Object.entries(responseMap)) {
21
+ // Extracting the path from the map key which is in format
22
+ // GET /path/foo
23
+ if (!key.startsWith(method)) {
24
+ continue;
25
+ }
26
+ const candidatePath = getPathFromMapKey(key);
27
+ // Get each part of the url path
28
+ const candidateParts = candidatePath.split("/");
29
+ // If the candidate and actual paths don't match in size
30
+ // we move on to the next candidate path
31
+ if (candidateParts.length === pathParts.length &&
32
+ hasParametrizedPath(key)) {
33
+ // track if we have found a match to return the values found.
34
+ let found = true;
35
+ for (let i = 0; i < candidateParts.length; i++) {
36
+ if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) &&
37
+ ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.endsWith("}"))) {
38
+ // If the current part of the candidate is a "template" part
39
+ // it is a match with the actual path part on hand
40
+ // skip as the parameterized part can match anything
41
+ continue;
42
+ }
43
+ // If the candidate part is not a template and
44
+ // the parts don't match mark the candidate as not found
45
+ // to move on with the next candidate path.
46
+ if (candidateParts[i] !== pathParts[i]) {
47
+ found = false;
48
+ break;
49
+ }
50
+ }
51
+ // We finished evaluating the current candidate parts
52
+ // if all parts matched we return the success values form
53
+ // the path mapping.
54
+ if (found) {
55
+ return value;
56
+ }
57
+ }
58
+ }
59
+ // No match was found, return an empty array.
60
+ return [];
61
+ }
62
+ function hasParametrizedPath(path) {
63
+ return path.includes("/{");
64
+ }
65
+ function getPathFromMapKey(mapKey) {
66
+ const pathStart = mapKey.indexOf("/");
67
+ return mapKey.slice(pathStart);
68
+ }
69
+ //# sourceMappingURL=isUnexpected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,MAAM,WAAW,GAA6B;IAC5C,8BAA8B,EAAE,CAAC,KAAK,CAAC;CACxC,CAAC;AAOF,MAAM,UAAU,YAAY,CAC1B,QAEyC;IAEzC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IA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AC,0CAAE,UAAU,CAAC,GAAG,CAAC;qBAClC,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA,EAChC;oBACA,4DAA4D;oBAC5D,kDAAkD;oBAClD,oDAAoD;oBACpD,SAAS;iBACV;gBAED,8CAA8C;gBAC9C,wDAAwD;gBACxD,2CAA2C;gBAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;oBACtC,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;aACF;YAED,qDAAqD;YACrD,yDAAyD;YACzD,oBAAoB;YACpB,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,6CAA6C;IAC7C,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n GeolocationGetLocation200Response,\n GeolocationGetLocationDefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /geolocation/ip/{format}\": [\"200\"]\n};\n\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse;\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (\n candidateParts.length === pathParts.length &&\n hasParametrizedPath(key)\n ) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.endsWith(\"}\")\n ) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
@@ -0,0 +1,25 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { getClient } from "@azure-rest/core-client";
4
+ /**
5
+ * Initialize a new instance of the class MapsGeolocationClient class.
6
+ * @param credentials type: KeyCredential
7
+ */
8
+ export default function createClient(credentials, options = {}) {
9
+ var _a, _b;
10
+ const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `https://atlas.microsoft.com`;
11
+ options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "1.0";
12
+ options = Object.assign(Object.assign({}, options), { credentials: {
13
+ apiKeyHeaderName: "subscription-key"
14
+ } });
15
+ const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;
16
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
17
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
18
+ : `${userAgentInfo}`;
19
+ options = Object.assign(Object.assign({}, options), { userAgentOptions: {
20
+ userAgentPrefix
21
+ } });
22
+ const client = getClient(baseUrl, credentials, options);
23
+ return client;
24
+ }
25
+ //# sourceMappingURL=mapsGeolocationClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapsGeolocationClient.js","sourceRoot":"","sources":["../../../src/generated/mapsGeolocationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAInE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE;;IAE3B,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,6BAA6B,CAAC;IACjE,OAAO,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,KAAK,CAAC;IACjD,OAAO,mCACF,OAAO,KACV,WAAW,EAAE;YACX,gBAAgB,EAAE,kBAAkB;SACrC,GACF,CAAC;IAEF,MAAM,aAAa,GAAG,6CAA6C,CAAC;IACpE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,mCACF,OAAO,KACV,gBAAgB,EAAE;YAChB,eAAe;SAChB,GACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CACtB,OAAO,EACP,WAAW,EACX,OAAO,CACiB,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsGeolocationClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of the class MapsGeolocationClient class.\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n credentials: KeyCredential,\n options: ClientOptions = {}\n): MapsGeolocationClient {\n const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;\n options.apiVersion = options.apiVersion ?? \"1.0\";\n options = {\n ...options,\n credentials: {\n apiKeyHeaderName: \"subscription-key\"\n }\n };\n\n const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix\n }\n };\n\n const client = getClient(\n baseUrl,\n credentials,\n options\n ) as MapsGeolocationClient;\n\n return client;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=outputModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputModels.js","sourceRoot":"","sources":["../../../src/generated/outputModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** This object is returned from a successful call to IP Address to country/region API */\nexport interface IpAddressToLocationResultOutput {\n /** The object containing the country/region information. */\n countryRegion?: CountryRegionOutput;\n /** The IP Address of the request. */\n ipAddress?: string;\n}\n\n/** The object containing the country/region information. */\nexport interface CountryRegionOutput {\n /** The IP Address's 2-character code [(ISO 3166-1)](https://www.iso.org/iso-3166-country-codes.html) of the country or region. Please note, IP address in ranges reserved for special purpose will return Null for country/region. */\n isoCode?: string;\n}\n\n/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */\nexport interface ErrorResponseOutput {\n /** The error object. */\n error?: ErrorDetailOutput;\n}\n\n/** The error detail. */\nexport interface ErrorDetailOutput {\n /** The error code. */\n code?: string;\n /** The error message. */\n message?: string;\n /** The error target. */\n target?: string;\n /** The error details. */\n details?: Array<ErrorDetailOutput>;\n /** The error additional info. */\n additionalInfo?: Array<ErrorAdditionalInfoOutput>;\n}\n\n/** The resource management error additional info. */\nexport interface ErrorAdditionalInfoOutput {\n /** The additional info type. */\n type?: string;\n /** The additional info. */\n info?: Record<string, unknown>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../src/generated/parameters.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestParameters } from \"@azure-rest/core-client\";\n\nexport interface GeolocationGetLocationQueryParamProperties {\n /** The IP address. Both IPv4 and IPv6 are allowed. */\n ip: string;\n}\n\nexport interface GeolocationGetLocationQueryParam {\n queryParameters: GeolocationGetLocationQueryParamProperties;\n}\n\nexport type GeolocationGetLocationParameters = GeolocationGetLocationQueryParam &\n RequestParameters;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../src/generated/responses.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpResponse } from \"@azure-rest/core-client\";\nimport {\n IpAddressToLocationResultOutput,\n ErrorResponseOutput\n} from \"./outputModels\";\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.\n */\nexport interface GeolocationGetLocation200Response extends HttpResponse {\n status: \"200\";\n body: IpAddressToLocationResultOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.\n */\nexport interface GeolocationGetLocationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import MapsGeolocation from "./MapsGeolocation";
4
+ export * from "./generated";
5
+ export default MapsGeolocation;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,cAAc,aAAa,CAAC;AAC5B,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsGeolocation from \"./MapsGeolocation\";\n\nexport * from \"./generated\";\nexport default MapsGeolocation;\n"]}
package/package.json ADDED
@@ -0,0 +1,130 @@
1
+ {
2
+ "name": "@azure-rest/maps-geolocation",
3
+ "sdk-type": "client",
4
+ "author": "Microsoft Corporation",
5
+ "version": "1.0.0-beta.1",
6
+ "description": "A generated SDK for MapsGeolocationClient.",
7
+ "keywords": [
8
+ "node",
9
+ "azure",
10
+ "cloud",
11
+ "typescript",
12
+ "browser",
13
+ "isomorphic"
14
+ ],
15
+ "license": "MIT",
16
+ "main": "dist/index.js",
17
+ "module": "./dist-esm/src/index.js",
18
+ "types": "./types/maps-geolocation-rest.d.ts",
19
+ "repository": "github:Azure/azure-sdk-for-js",
20
+ "bugs": {
21
+ "url": "https://github.com/Azure/azure-sdk-for-js/issues"
22
+ },
23
+ "files": [
24
+ "dist/",
25
+ "dist-esm/src/",
26
+ "types/maps-geolocation-rest.d.ts",
27
+ "README.md",
28
+ "LICENSE",
29
+ "review/*"
30
+ ],
31
+ "engines": {
32
+ "node": ">=14.0.0"
33
+ },
34
+ "scripts": {
35
+ "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
36
+ "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
37
+ "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
38
+ "build:samples": "dev-tool samples publish --force",
39
+ "build:test": "tsc -p . && dev-tool run bundle",
40
+ "build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
41
+ "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
42
+ "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
43
+ "execute:samples": "dev-tool samples run samples-dev",
44
+ "extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
45
+ "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
46
+ "generate:client": "autorest --typescript swagger/README.md && npm run format",
47
+ "integration-test:browser": "dev-tool run test:browser",
48
+ "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
49
+ "integration-test": "npm run integration-test:node && npm run integration-test:browser",
50
+ "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
51
+ "lint": "eslint package.json api-extractor.json src test --ext .ts",
52
+ "pack": "npm pack 2>&1",
53
+ "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
54
+ "test:node": "npm run clean && npm run build:test && npm run unit-test:node",
55
+ "test": "npm run clean && npm run build:test && npm run unit-test",
56
+ "unit-test": "npm run unit-test:node && npm run unit-test:browser",
57
+ "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
58
+ "unit-test:browser": "dev-tool run test:browser",
59
+ "build": "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local"
60
+ },
61
+ "sideEffects": false,
62
+ "autoPublish": false,
63
+ "dependencies": {
64
+ "@azure/core-auth": "^1.3.0",
65
+ "@azure-rest/core-client": "1.0.0-beta.10",
66
+ "@azure/core-rest-pipeline": "^1.8.0",
67
+ "@azure/maps-common": "^1.0.0-beta.2",
68
+ "tslib": "^2.2.0"
69
+ },
70
+ "devDependencies": {
71
+ "@microsoft/api-extractor": "^7.31.1",
72
+ "autorest": "latest",
73
+ "@types/node": "^14.0.0",
74
+ "dotenv": "^8.2.0",
75
+ "eslint": "^8.0.0",
76
+ "mkdirp": "^1.0.4",
77
+ "prettier": "^2.5.1",
78
+ "rimraf": "^3.0.0",
79
+ "source-map-support": "^0.5.9",
80
+ "typescript": "~4.6.0",
81
+ "@azure/dev-tool": "^1.0.0",
82
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
83
+ "@azure-tools/test-credential": "^1.0.0",
84
+ "@azure/identity": "^2.0.1",
85
+ "@azure-tools/test-recorder": "^2.0.0",
86
+ "mocha": "^7.1.1",
87
+ "@types/mocha": "^7.0.2",
88
+ "mocha-junit-reporter": "^1.18.0",
89
+ "cross-env": "^7.0.2",
90
+ "@types/chai": "^4.2.8",
91
+ "chai": "^4.2.0",
92
+ "karma-chrome-launcher": "^3.0.0",
93
+ "karma-coverage": "^2.0.0",
94
+ "karma-edge-launcher": "^0.4.2",
95
+ "karma-env-preprocessor": "^0.1.1",
96
+ "karma-firefox-launcher": "^1.1.0",
97
+ "karma-ie-launcher": "^1.0.0",
98
+ "karma-junit-reporter": "^2.0.1",
99
+ "karma-mocha-reporter": "^2.2.5",
100
+ "karma-mocha": "^2.0.1",
101
+ "karma-source-map-support": "~1.4.0",
102
+ "karma-sourcemap-loader": "^0.3.8",
103
+ "karma": "^6.2.0",
104
+ "nyc": "^15.0.0",
105
+ "@azure/test-utils": "~1.0.0"
106
+ },
107
+ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-geolocation-rest/README.md",
108
+ "//metadata": {
109
+ "constantPaths": [
110
+ {
111
+ "path": "swagger/README.md",
112
+ "prefix": "package-version"
113
+ }
114
+ ]
115
+ },
116
+ "browser": {
117
+ "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js"
118
+ },
119
+ "//sampleConfiguration": {
120
+ "productName": "MapsGeolocationClient",
121
+ "productSlugs": [
122
+ "azure",
123
+ "azure-maps"
124
+ ],
125
+ "requiredResources": {
126
+ "Azure Maps Resource": "https://docs.microsoft.com/azure/azure-maps/how-to-create-template"
127
+ },
128
+ "disableDocsMs": true
129
+ }
130
+ }
@@ -0,0 +1,103 @@
1
+ ## API Report File for "@azure-rest/maps-geolocation"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { AzureKeyCredential } from '@azure/core-auth';
8
+ import { Client } from '@azure-rest/core-client';
9
+ import { ClientOptions } from '@azure-rest/core-client';
10
+ import { HttpResponse } from '@azure-rest/core-client';
11
+ import { RequestParameters } from '@azure-rest/core-client';
12
+ import { StreamableMethod } from '@azure-rest/core-client';
13
+ import { TokenCredential } from '@azure/core-auth';
14
+
15
+ // @public
16
+ export interface CountryRegionOutput {
17
+ isoCode?: string;
18
+ }
19
+
20
+ // @public
21
+ export interface ErrorAdditionalInfoOutput {
22
+ info?: Record<string, unknown>;
23
+ type?: string;
24
+ }
25
+
26
+ // @public
27
+ export interface ErrorDetailOutput {
28
+ additionalInfo?: Array<ErrorAdditionalInfoOutput>;
29
+ code?: string;
30
+ details?: Array<ErrorDetailOutput>;
31
+ message?: string;
32
+ target?: string;
33
+ }
34
+
35
+ // @public
36
+ export interface ErrorResponseOutput {
37
+ error?: ErrorDetailOutput;
38
+ }
39
+
40
+ // @public
41
+ export interface GeolocationGetLocation200Response extends HttpResponse {
42
+ // (undocumented)
43
+ body: IpAddressToLocationResultOutput;
44
+ // (undocumented)
45
+ status: "200";
46
+ }
47
+
48
+ // @public
49
+ export interface GeolocationGetLocationDefaultResponse extends HttpResponse {
50
+ // (undocumented)
51
+ body: ErrorResponseOutput;
52
+ // (undocumented)
53
+ status: string;
54
+ }
55
+
56
+ // @public (undocumented)
57
+ export type GeolocationGetLocationParameters = GeolocationGetLocationQueryParam & RequestParameters;
58
+
59
+ // @public (undocumented)
60
+ export interface GeolocationGetLocationQueryParam {
61
+ // (undocumented)
62
+ queryParameters: GeolocationGetLocationQueryParamProperties;
63
+ }
64
+
65
+ // @public (undocumented)
66
+ export interface GeolocationGetLocationQueryParamProperties {
67
+ ip: string;
68
+ }
69
+
70
+ // @public (undocumented)
71
+ export interface GetLocation {
72
+ get(options: GeolocationGetLocationParameters): StreamableMethod<GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse>;
73
+ }
74
+
75
+ // @public
76
+ export interface IpAddressToLocationResultOutput {
77
+ countryRegion?: CountryRegionOutput;
78
+ ipAddress?: string;
79
+ }
80
+
81
+ // @public (undocumented)
82
+ export function isUnexpected(response: GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse): response is GeolocationGetLocationDefaultResponse;
83
+
84
+ // @public
85
+ function MapsGeolocation(credential: AzureKeyCredential, options?: ClientOptions): MapsGeolocationClient;
86
+
87
+ // @public
88
+ function MapsGeolocation(credential: TokenCredential, mapsAccountClientId: string, options?: ClientOptions): MapsGeolocationClient;
89
+ export default MapsGeolocation;
90
+
91
+ // @public (undocumented)
92
+ export type MapsGeolocationClient = Client & {
93
+ path: Routes;
94
+ };
95
+
96
+ // @public (undocumented)
97
+ export interface Routes {
98
+ (path: "/geolocation/ip/{format}", format: "json"): GetLocation;
99
+ }
100
+
101
+ // (No @packageDocumentation comment for this package)
102
+
103
+ ```
@@ -0,0 +1,141 @@
1
+ import { AzureKeyCredential } from '@azure/core-auth';
2
+ import { Client } from '@azure-rest/core-client';
3
+ import { ClientOptions } from '@azure-rest/core-client';
4
+ import { HttpResponse } from '@azure-rest/core-client';
5
+ import { RequestParameters } from '@azure-rest/core-client';
6
+ import { StreamableMethod } from '@azure-rest/core-client';
7
+ import { TokenCredential } from '@azure/core-auth';
8
+
9
+ /** The object containing the country/region information. */
10
+ export declare interface CountryRegionOutput {
11
+ /** The IP Address's 2-character code [(ISO 3166-1)](https://www.iso.org/iso-3166-country-codes.html) of the country or region. Please note, IP address in ranges reserved for special purpose will return Null for country/region. */
12
+ isoCode?: string;
13
+ }
14
+
15
+ /** The resource management error additional info. */
16
+ export declare interface ErrorAdditionalInfoOutput {
17
+ /** The additional info type. */
18
+ type?: string;
19
+ /** The additional info. */
20
+ info?: Record<string, unknown>;
21
+ }
22
+
23
+ /** The error detail. */
24
+ export declare interface ErrorDetailOutput {
25
+ /** The error code. */
26
+ code?: string;
27
+ /** The error message. */
28
+ message?: string;
29
+ /** The error target. */
30
+ target?: string;
31
+ /** The error details. */
32
+ details?: Array<ErrorDetailOutput>;
33
+ /** The error additional info. */
34
+ additionalInfo?: Array<ErrorAdditionalInfoOutput>;
35
+ }
36
+
37
+ /** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */
38
+ export declare interface ErrorResponseOutput {
39
+ /** The error object. */
40
+ error?: ErrorDetailOutput;
41
+ }
42
+
43
+ /**
44
+ * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).
45
+ *
46
+ *
47
+ * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
48
+ */
49
+ export declare interface GeolocationGetLocation200Response extends HttpResponse {
50
+ status: "200";
51
+ body: IpAddressToLocationResultOutput;
52
+ }
53
+
54
+ /**
55
+ * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).
56
+ *
57
+ *
58
+ * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
59
+ */
60
+ export declare interface GeolocationGetLocationDefaultResponse extends HttpResponse {
61
+ status: string;
62
+ body: ErrorResponseOutput;
63
+ }
64
+
65
+ export declare type GeolocationGetLocationParameters = GeolocationGetLocationQueryParam & RequestParameters;
66
+
67
+ export declare interface GeolocationGetLocationQueryParam {
68
+ queryParameters: GeolocationGetLocationQueryParamProperties;
69
+ }
70
+
71
+ export declare interface GeolocationGetLocationQueryParamProperties {
72
+ /** The IP address. Both IPv4 and IPv6 are allowed. */
73
+ ip: string;
74
+ }
75
+
76
+ export declare interface GetLocation {
77
+ /**
78
+ * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).
79
+ *
80
+ *
81
+ * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
82
+ */
83
+ get(options: GeolocationGetLocationParameters): StreamableMethod<GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse>;
84
+ }
85
+
86
+ /** This object is returned from a successful call to IP Address to country/region API */
87
+ export declare interface IpAddressToLocationResultOutput {
88
+ /** The object containing the country/region information. */
89
+ countryRegion?: CountryRegionOutput;
90
+ /** The IP Address of the request. */
91
+ ipAddress?: string;
92
+ }
93
+
94
+ export declare function isUnexpected(response: GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse): response is GeolocationGetLocationDefaultResponse;
95
+
96
+ /**
97
+ * Creates an instance of MapsGeolocationClient from a subscription key.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import MapsGeolocation from "@azure-rest/maps-geolocation";
102
+ * import { AzureKeyCredential } from "@azure/core-auth";
103
+ *
104
+ * const credential = new AzureKeyCredential("<subscription-key>");
105
+ * const client = MapsGeolocation(credential);
106
+ *```
107
+ *
108
+ * @param credential - An AzureKeyCredential instance used to authenticate requests to the service
109
+ * @param options - Options used to configure the Geolocation Client
110
+ */
111
+ declare function MapsGeolocation(credential: AzureKeyCredential, options?: ClientOptions): MapsGeolocationClient;
112
+
113
+ /**
114
+ * Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * import MapsGeolocation from "@azure/maps-geo-location";
119
+ * import { DefaultAzureCredential } from "@azure/identity";
120
+ *
121
+ * const credential = new DefaultAzureCredential();
122
+ * const client = MapsGeolocation(credential, "<maps-account-client-id>");
123
+ *```
124
+ *
125
+ * @param credential - An TokenCredential instance used to authenticate requests to the service
126
+ * @param mapsAccountClientId - The Azure Maps client id of a specific map resource
127
+ * @param options - Options used to configure the Route Client
128
+ */
129
+ declare function MapsGeolocation(credential: TokenCredential, mapsAccountClientId: string, options?: ClientOptions): MapsGeolocationClient;
130
+ export default MapsGeolocation;
131
+
132
+ export declare type MapsGeolocationClient = Client & {
133
+ path: Routes;
134
+ };
135
+
136
+ export declare interface Routes {
137
+ /** Resource for '/geolocation/ip/\{format\}' has methods for the following verbs: get */
138
+ (path: "/geolocation/ip/{format}", format: "json"): GetLocation;
139
+ }
140
+
141
+ export { }