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

[Communication] -Administration- changing some createReservation from public to private #17576

Merged
merged 3 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
270 changes: 135 additions & 135 deletions sdk/communication/azure-communication-administration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Acquired phone numbers can come with many capabilities, depending on the country
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-administration</artifactId>
<version>1.0.0-beta.2</version>
<version>1.0.0-beta.3</version>
</dependency>
```

Expand All @@ -39,47 +39,47 @@ via the endpoint() and httpClient() functions respectively.

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L37-L48 -->
```java
// You can find your endpoint and access key from your resource in the Azure Portal
paolamvhz marked this conversation as resolved.
Show resolved Hide resolved
String endpoint = "https://<RESOURCE_NAME>.communication.azure.com";
String accessKey = "SECRET";

// Create an HttpClient builder of your choice and customize it
HttpClient httpClient = new NettyAsyncHttpClientBuilder().build();

CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClientBuilder()
.endpoint(endpoint)
.accessKey(accessKey)
.httpClient(httpClient)
.buildClient();












```

Alternatively, you can provide the entire connection string using the connectionString() function instead of providing the endpoint and access key.
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L62-L68 -->
```java
// Your can find your connection string from your resource in the Azure Portal
paolamvhz marked this conversation as resolved.
Show resolved Hide resolved
String connectionString = "<connection_string>";

CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClientBuilder()
.connectionString(connectionString)
.httpClient(httpClient)
.buildClient();






```
### Initializing Phone Number Client

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L128-L139 -->
```java
// You can find your endpoint and access token from your resource in the Azure Portal
String endpoint = "https://<RESOURCE_NAME>.communication.azure.com";
String accessKey = "SECRET";

// Create an HttpClient builder of your choice and customize it
HttpClient httpClient = new NettyAsyncHttpClientBuilder().build();

PhoneNumberClient phoneNumberClient = new PhoneNumberClientBuilder()
.endpoint(endpoint)
.accessKey(accessKey)
.httpClient(httpClient)
.buildClient();












```
Alternatively, you can provide the entire connection string using the connectionString() function of the PhoneNumberClientBuilder instead of providing the endpoint and access key.

Expand All @@ -105,8 +105,8 @@ unique ID of the user that was created.

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L80-L81 -->
```java
CommunicationUser user = communicationIdentityClient.createUser();
System.out.println("User id: " + user.getId());
return user;
```

### Issuing or Refreshing a token for an existing user
Expand All @@ -118,44 +118,44 @@ also takes in a list of communication token scopes. Scope options include:

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L93-L96 -->
```java
List<String> scopes = new ArrayList<>(Arrays.asList("chat"));
CommunicationUserToken userToken = communicationIdentityClient.issueToken(user, scopes);
System.out.println("Token: " + userToken.getToken());
System.out.println("Expires On: " + userToken.getExpiresOn());
return userToken;
```

### Revoking all tokens for an existing user
Use the `revokeTokens` function to revoke all the issued tokens of a user.

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L108-L109 -->
```java
// revoke tokens issued for the user prior to now
paolamvhz marked this conversation as resolved.
Show resolved Hide resolved
communicationIdentityClient.revokeTokens(user, OffsetDateTime.now());
communicationIdentityClient.revokeTokens(user, OffsetDateTime.now());
}
```

### Deleting a user
Use the `deleteUser` function to delete a user.

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L118-L119 -->
```java
// delete a previously created user
communicationIdentityClient.deleteUser(user);
communicationIdentityClient.deleteUser(user);
}
```

### Get Countries

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L151-L160 -->
```java
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

PagedIterable<PhoneNumberCountry> phoneNumberCountries = phoneNumberClient
.listAllSupportedCountries(locale);

for (PhoneNumberCountry phoneNumberCountry
: phoneNumberCountries) {
System.out.println("Phone Number Country Code: " + phoneNumberCountry.getCountryCode());
System.out.println("Phone Number Country Name: " + phoneNumberCountry.getLocalizedName());
}








```

### Get Phone Plan Groups
Expand All @@ -164,16 +164,16 @@ Phone plan groups come in two types, Geographic and Toll-Free.

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L193-L202 -->
```java
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

PagedIterable<PhonePlanGroup> phonePlanGroups = phoneNumberClient
.listPhonePlanGroups(countryCode, locale, true);

for (PhonePlanGroup phonePlanGroup
: phonePlanGroups) {
System.out.println("Phone Plan GroupId: " + phonePlanGroup.getPhonePlanGroupId());
System.out.println("Phone Plan NumberType: " + phonePlanGroup.getPhoneNumberType());
}








```

### Get Phone Plans
Expand All @@ -182,18 +182,18 @@ Unlike Toll-Free phone plans, area codes for Geographic Phone Plans are empty. A

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L216-L227 -->
```java
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

PagedIterable<PhonePlan> phonePlans = phoneNumberClient
.listPhonePlans(countryCode, phonePlanGroupId, locale);

for (PhonePlan phonePlan
: phonePlans) {
System.out.println("Phone Plan Id: " + phonePlan.getPhonePlanId());
System.out.println("Phone Plan Name: " + phonePlan.getLocalizedName());
System.out.println("Phone Plan Capabilities: " + phonePlan.getCapabilities());
System.out.println("Phone Plan Area Codes: " + phonePlan.getAreaCodes());
}










```

### Get Location Options
Expand All @@ -202,25 +202,25 @@ For Geographic phone plans, you can query the available geographic locations. Th

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L242-L260 -->
```java
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

LocationOptions locationOptions = phoneNumberClient
.getPhonePlanLocationOptions(countryCode, phonePlanGroupId, phonePlanId, locale)
.getLocationOptions();

System.out.println("Getting LocationOptions for: " + locationOptions.getLabelId());
for (LocationOptionsDetails locationOptionsDetails
: locationOptions.getOptions()) {
System.out.println(locationOptionsDetails.getValue());
for (LocationOptions locationOptions1
: locationOptionsDetails.getLocationOptions()) {
System.out.println("Getting LocationOptions for: " + locationOptions1.getLabelId());
for (LocationOptionsDetails locationOptionsDetails1
: locationOptions1.getOptions()) {
System.out.println(locationOptionsDetails1.getValue());
}
}
}



















```

### Get Area Codes
Expand All @@ -229,22 +229,22 @@ Fetching area codes for geographic phone plans will require the the location opt

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L284-L292 -->
```java
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

AreaCodes areaCodes = phoneNumberClient
.getAllAreaCodes("selection", countryCode, phonePlanId, locationOptions);

for (String areaCode
: areaCodes.getPrimaryAreaCodes()) {
System.out.println(areaCode);
}







```

### Configure Phone Number

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L338-L338 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L306-L306 -->
```java
phoneNumberClient.configureNumber(phoneNumber, pstnConfiguration);
}
```

## Long Running Operations
Expand All @@ -253,61 +253,61 @@ The Phone Number Client supports a variety of long running operations that allow

### Create Search

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L345-L369 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L313-L337 -->
```java
String phonePlanId = "PHONE_PLAN_ID";

List<String> phonePlanIds = new ArrayList<>();
phonePlanIds.add(phonePlanId);

CreateReservationOptions createReservationOptions = new CreateReservationOptions();
createReservationOptions
.setAreaCode("AREA_CODE_FOR_RESERVATION")
.setDescription("DESCRIPTION_FOR_RESERVATION")
.setDisplayName("NAME_FOR_RESERVATION")
.setPhonePlanIds(phonePlanIds)
.setQuantity(2);

Duration duration = Duration.ofSeconds(1);
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<PhoneNumberReservation, PhoneNumberReservation> res =
phoneNumberClient.beginCreateReservation(createReservationOptions, duration);
res.waitForCompletion();
PhoneNumberReservation result = res.getFinalResult();

System.out.println("Reservation Id: " + result.getReservationId());
for (String phoneNumber: result.getPhoneNumbers()) {
System.out.println("Phone Number: " + phoneNumber);

List<String> phonePlanIds = new ArrayList<>();
phonePlanIds.add(phonePlanId);

CreateReservationOptions createReservationOptions = new CreateReservationOptions();
createReservationOptions
.setAreaCode("AREA_CODE_FOR_RESERVATION")
.setDescription("DESCRIPTION_FOR_RESERVATION")
.setDisplayName("NAME_FOR_RESERVATION")
.setPhonePlanIds(phonePlanIds)
.setQuantity(2);

Duration duration = Duration.ofSeconds(1);
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<PhoneNumberReservation, PhoneNumberReservation> res =
phoneNumberClient.beginCreateReservation(createReservationOptions, duration);
res.waitForCompletion();
PhoneNumberReservation result = res.getFinalResult();

System.out.println("Reservation Id: " + result.getReservationId());
for (String phoneNumber: result.getPhoneNumbers()) {
System.out.println("Phone Number: " + phoneNumber);
}
}
```

### Purchase Search
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L376-L382 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L344-L350 -->
```java
Duration duration = Duration.ofSeconds(1);
String phoneNumberReservationId = "RESERVATION_ID_TO_PURCHASE";
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();
String phoneNumberReservationId = "RESERVATION_ID_TO_PURCHASE";
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<Void, Void> res =
phoneNumberClient.beginPurchaseReservation(phoneNumberReservationId, duration);
res.waitForCompletion();
SyncPoller<Void, Void> res =
phoneNumberClient.beginPurchaseReservation(phoneNumberReservationId, duration);
res.waitForCompletion();
}
```

### Release Phone Numbers
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L389-L399 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L357-L367 -->
```java
Duration duration = Duration.ofSeconds(1);
PhoneNumber phoneNumber = new PhoneNumber("PHONE_NUMBER_TO_RELEASE");
List<PhoneNumber> phoneNumbers = new ArrayList<>();
phoneNumbers.add(phoneNumber);
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<PhoneNumberRelease, PhoneNumberRelease> res =
phoneNumberClient.beginReleasePhoneNumbers(phoneNumbers, duration);
res.waitForCompletion();
PhoneNumberRelease result = res.getFinalResult();
System.out.println("Phone number release status: " + result.getStatus());
PhoneNumber phoneNumber = new PhoneNumber("PHONE_NUMBER_TO_RELEASE");
List<PhoneNumber> phoneNumbers = new ArrayList<>();
phoneNumbers.add(phoneNumber);
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<PhoneNumberRelease, PhoneNumberRelease> res =
phoneNumberClient.beginReleasePhoneNumbers(phoneNumbers, duration);
res.waitForCompletion();
PhoneNumberRelease result = res.getFinalResult();
System.out.println("Phone number release status: " + result.getStatus());
}
```

## Contributing
Expand Down
Loading