ユーザーの削除

このコードスニペットでは、ユーザを削除する方法を説明します。

以下の変数が、便利な方法で必要な値に設定されていることを確認してください:

キー説明
USER_ID

The unique ID of the User.

前提条件

You will need to use an existing Application and have a User in order to be able to delete a User. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.

コードを書く

delete-user.sh に以下を追加する:

curl -X "DELETE" "https://api.nexmo.com/v1/users/$USER_ID" \
     -H 'Authorization: Bearer '$JWT\
     -H 'Content-Type: application/json'

全文を見る

コードを実行する

このファイルをあなたのマシンに保存し、実行する:

bash delete-user.sh

前提条件

You will need to use an existing Application and have a User in order to be able to delete a User. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
npm install @vonage/server-sdk

delete-user.js という名前のファイルを作成し、以下のコードを追加する:

const { Vonage } = require('@vonage/server-sdk');

const vonage = new Vonage({
  applicationId: VONAGE_APPLICATION_ID,
  privateKey: VONAGE_PRIVATE_KEY,
});

全文を見る

コードを書く

delete-user.js に以下を追加する:

vonage.users.deleteUser(USER_ID)
  .then(() => console.log('User deleted'))
  .catch((error) => console.error(error));

全文を見る

コードを実行する

このファイルをあなたのマシンに保存し、実行する:

node delete-user.js

前提条件

You will need to use an existing Application and have a User in order to be able to delete a User. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.

build.gradle に以下を追加する:

implementation 'com.vonage:server-sdk-kotlin:2.1.1'

DeleteUser という名前のファイルを作成し、main メソッドに以下のコードを追加する:

val client = Vonage {
    applicationId(VONAGE_APPLICATION_ID)
    privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
}

全文を見る

コードを書く

DeleteUser ファイルのmain メソッドに以下を追加する:

client.users.user(USER_ID).delete()

全文を見る

コードを実行する

Gradle用のアプリケーション プラグインを使うことで、アプリケーションの実行を簡単にすることができます。build.gradle を以下のように更新する:

apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''

以下のgradle コマンドを実行し、com.vonage.quickstart.kt.usersDeleteUser を含むパッケージに置き換えてアプリケーションを実行する:

gradle run -Pmain=com.vonage.quickstart.kt.users.DeleteUser

前提条件

You will need to use an existing Application and have a User in order to be able to delete a User. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.

build.gradle に以下を追加する:

implementation 'com.vonage:server-sdk:9.3.1'

DeleteUser という名前のファイルを作成し、main メソッドに以下のコードを追加する:

VonageClient client = VonageClient.builder()
        .apiKey(VONAGE_API_KEY)
        .apiSecret(VONAGE_API_SECRET)
        .build();

全文を見る

コードを書く

DeleteUser ファイルのmain メソッドに以下を追加する:

client.getUsersClient().deleteUser(USER_ID);

全文を見る

コードを実行する

Gradle用のアプリケーション プラグインを使うことで、アプリケーションの実行を簡単にすることができます。build.gradle を以下のように更新する:

apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''

以下のgradle コマンドを実行し、com.vonage.quickstart.usersDeleteUser を含むパッケージに置き換えてアプリケーションを実行する:

gradle run -Pmain=com.vonage.quickstart.users.DeleteUser

前提条件

You will need to use an existing Application and have a User in order to be able to delete a User. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
Install-Package Vonage

DeleteUser.cs という名前のファイルを作成し、以下のコードを追加する:

using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Vonage;
using Vonage.Request;
using Vonage.Users.DeleteUser;

全文を見る

DeleteUser.cs に以下を追加する:

var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH);
var client = new VonageClient(credentials);

全文を見る

コードを書く

DeleteUser.cs に以下を追加する:

var response = await client.UsersClient.DeleteUserAsync(DeleteUserRequest.Parse(USER_ID));

全文を見る

前提条件

You will need to use an existing Application and have a User in order to be able to delete a User. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
pip install vonage python-dotenv

コードを書く

delete-user.py に以下を追加する:

from vonage import Auth, Vonage

client = Vonage(
    Auth(
        application_id=VONAGE_APPLICATION_ID,
        private_key=VONAGE_PRIVATE_KEY,
    )
)
client.users.delete_user(USER_ID)

全文を見る

コードを実行する

このファイルをあなたのマシンに保存し、実行する:

python users/delete-user.py

試してみる

コードを実行すると、指定したユーザが削除されます。