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

Add SDK for Tiering #26121

Merged
merged 24 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c7f122d
Rush config files
classBabacar-msft May 18, 2023
1770290
SDK for tiering
classBabacar-msft May 18, 2023
e2f8099
autorest code for tiering
classBabacar-msft May 26, 2023
4bf82ff
updating swagger
classBabacar-msft May 26, 2023
514f781
updating swagger.json
classBabacar-msft Jun 1, 2023
5236e53
Changing function name in client
classBabacar-msft Jun 1, 2023
03bde07
updating samples
classBabacar-msft Jun 5, 2023
bb256fc
generated code
classBabacar-msft Jun 5, 2023
00711a1
api extractor
classBabacar-msft Jun 5, 2023
ab99bc8
updating the swagger
classBabacar-msft Jun 5, 2023
88021ff
tests
classBabacar-msft Jun 5, 2023
aebd56f
coverage generator
classBabacar-msft Jun 5, 2023
ce6b226
adding documentation
classBabacar-msft Jun 5, 2023
8e4848b
removing apiref
classBabacar-msft Jun 5, 2023
81c9c95
Merge branch 'main' into bndoye/sdkForTiering
classBabacar-msft Jun 6, 2023
96581d0
rush updating
classBabacar-msft Jun 7, 2023
1dc9f70
Adding unknown word and editing readme
classBabacar-msft Jun 8, 2023
6e42803
Merge branch 'main' into bndoye/sdkForTiering
classBabacar-msft Jun 12, 2023
ab11c86
Addressing PR Comments
classBabacar-msft Jun 14, 2023
82ec663
updating beta version
classBabacar-msft Jun 14, 2023
3398bab
versioning
classBabacar-msft Jun 14, 2023
f1df02f
Merge branch 'main' into bndoye/sdkForTiering
classBabacar-msft Jun 15, 2023
16e6e94
Adding environment variables to test
classBabacar-msft Jun 16, 2023
4130fc8
Removing hardcoded environment variable for tests
classBabacar-msft Jun 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"Eugps",
"EUGPS",
"Fhir",
"Fnhr",
"Guids",
"Hana",
"Idrg",
Expand Down Expand Up @@ -107,10 +108,11 @@
"prettierrc",
"pwsh",
"Rasterize",
"reoffer",
"Resourceid",
"Rollup",
"rrggbb",
"Rtsp",
"reoffer",
"rushx",
"soundex",
"southcentralus",
Expand Down Expand Up @@ -246,7 +248,9 @@
},
{
"filename": "sdk/formrecognizer/ai-form-recognizer/README.md",
"words": ["iddocument"]
"words": [
"iddocument"
]
},
{
"filename": "sdk/formrecognizer/ai-form-recognizer/review/**/*.md",
Expand Down
46 changes: 46 additions & 0 deletions common/config/rush/pnpm-lock.yaml

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

5 changes: 5 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@
"projectFolder": "sdk/communication/communication-recipient-verification",
"versionPolicyName": "client"
},
{
"packageName": "@azure-tools/communication-tiering",
"projectFolder": "sdk/communication/communication-tiering",
"versionPolicyName": "client"
},
{
"packageName": "@azure-tools/communication-alpha-ids",
"projectFolder": "sdk/communication/communication-alpha-ids",
Expand Down
10 changes: 10 additions & 0 deletions sdk/communication/communication-tiering/.nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": ["dist-esm/src/**/*.js"],
"exclude": ["**/*.d.ts", "dist-esm/src/generated/*"],
"reporter": ["text-summary", "html", "cobertura"],
"exclude-after-remap": false,
"sourceMap": true,
"produce-source-map": true,
"instrument": true,
"all": true
}
8 changes: 8 additions & 0 deletions sdk/communication/communication-tiering/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Release History

## 1.0.0-beta.0 (2023-06-05)

The first preview of the Azure Communication Tiering client library has the following features:

- Retrieving tiering info
- Retrieving telephone number summary
142 changes: 142 additions & 0 deletions sdk/communication/communication-tiering/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Azure Communication Tiering client library for JavaScript

The Tiering client library allows developers to retrieve limits for each capability (SMS/PSTN Calling/Phone Number purchasing) for a specific resource/tier.

## Getting started

### Prerequisites

- An [Azure subscription][azure_sub].
- An existing Communication Services resource. If you need to create the resource, you can use the [Azure Portal][azure_portal], the [Azure PowerShell][azure_powershell], or the [Azure CLI][azure_cli].

### Installing

```bash
npm install @azure-tools/communication-tiering
```

### Browser support

#### JavaScript Bundle

To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).

## Key concepts

## Examples

## Authentication

To create a client object to access the Communication Services API, you will need a `connection string` or the `endpoint` of your Communication Services resource and a `credential`. The Tiering client can use either Azure Active Directory credentials or an API key credential to authenticate.

You can get a key and/or connection string from your Communication Services resource in the [Azure Portal][azure_portal]. You can also find the endpoint for your Communication Services resource in the [Azure Portal][azure_portal].

Once you have a key, you can authenticate the `TieringClient` with any of the following methods:

### Using a connection string

```javascript
const { TieringClient } = require("@azure-tools/communication-tiering");
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
const client = new TieringClient(connectionString);
```

### Using an access key with `AzureKeyCredential`

If you use a key to initialize the client you will also need to provide the appropriate endpoint. You can get this endpoint from your Communication Services resource in [Azure Portal][azure_portal]. Once you have a key and endpoint, you can authenticate with the following code:

```javascript
const { AzureKeyCredential } = require("@azure/core-auth");
const { TieringClient } = require("@azure-tools/communication-tiering");
const credential = new AzureKeyCredential("<key-from-resource>");
const client = new TieringClient("<endpoint-from-resource>", credential);
```

### Using an Azure Active Directory Credential

Connection string authentication is used in most of the examples, but you can also authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the [`@azure/identity`][azure_identity] package:

```bash
npm install @azure/identity
```

The [`@azure/identity`][azure_identity] package provides a variety of credential types that your application can use to do this. The [README for `@azure/identity`][azure_identity_readme] provides more details and samples to get you started.

```javascript
const { DefaultAzureCredential } = require("@azure/identity");
const { TieringClient } = require("@azure-tools/communication-tiering");

let credential = new DefaultAzureCredential();
const client = new TieringClient("<endpoint-from-resource>", credential);
```

## Usage

The following sections provide code snippets that cover some of the common tasks using the Azure Communication Services Tiering Client. The scenarios that are covered here consist of:

- [Get acquired number limits](#get-acquired-number-limits)
- [Get Tier Info](#get-tier-info)

### Get acquired number limits

```typescript
import { Tiering } from "@azure-tools/communication-tiering";
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
const client = new Tiering(connectionString);

async main function() {
const resourceId = "5d41e908-de88-4bbf-94dc-fe9a1b51029b";

// Get acquired numbers and limits for a resource
var acquiredNumberLimits = await client.getAcquiredNumberLimits(resourceId);

// print all number limits
console.log(acquiredNumberLimits);
}

main();
```

### Get tier info

```typescript
import { Tiering } from "@azure-tools/communication-tiering";
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
const client = new Tiering(connectionString);

async main function() {
const resourceId = "5d41e908-de88-4bbf-94dc-fe9a1b51029b";

// Get tier info for a resource
var tierInfo = await client.getTierByResourceId(resourceId);

// print all tier info
console.log(tierInfo);
}

main();
```

## Troubleshooting

## Next steps

Please take a look at the samples directory for detailed examples on how to use this library.

## Contributing

If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.

## Related projects

- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)

[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_sub]: https://azure.microsoft.com/free/
[azure_portal]: https://portal.azure.com
[azure_powershell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
[azure_identity_readme]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcommunication%2Fcommunication-toll-free-verification%2FREADME.png)
35 changes: 35 additions & 0 deletions sdk/communication/communication-tiering/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"docModel": {
"enabled": true
},
"apiReport": {
"enabled": true,
"reportFolder": "./review"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/communication-tiering.d.ts"
},
"messages": {
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
},
"extractorMessageReporting": {
"ae-forgotten-export": {
"logLevel": "error",
"addToApiReportFile": false
},
"ae-missing-release-tag": {
"logLevel": "none"
},
"ae-unresolved-link": {
"logLevel": "error"
}
}
}
}
Loading