Merged PR 329: API実装(BlobStorageのコンテナを削除する)
## 概要 [Task2395: API実装(BlobStorageのコンテナを削除する)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2395) - BlobStorageコンテナを削除するgatewayメソッドを実装しました。 ## レビューポイント - 処理内容に問題はないか - コンテナの有無を見て結果を返すように実装したが作りとして問題はないか ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
f79e45be66
commit
deb753b40d
@ -83,6 +83,49 @@ export class BlobstorageService {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたコンテナを削除します。(コンテナが存在しない場合、何もせず終了します)
|
||||
* @param context
|
||||
* @param accountId
|
||||
* @param country
|
||||
*/
|
||||
async deleteContainer(
|
||||
context: Context,
|
||||
accountId: number,
|
||||
country: string,
|
||||
): Promise<void> {
|
||||
this.logger.log(
|
||||
`[IN] [${context.trackingId}] ${this.deleteContainer.name}`,
|
||||
);
|
||||
|
||||
try {
|
||||
// 国に応じたリージョンでコンテナ名を指定してClientを取得
|
||||
const containerClient = this.getContainerClient(accountId, country);
|
||||
const { succeeded, errorCode, date } =
|
||||
await containerClient.deleteIfExists();
|
||||
this.logger.log(
|
||||
`succeeded: ${succeeded}, errorCode: ${errorCode}, date: ${date}`,
|
||||
);
|
||||
|
||||
// 失敗時、コンテナが存在しない場合以外はエラーとして例外をスローする
|
||||
// コンテナ不在の場合のエラーコードは「ContainerNotFound」以下を参照
|
||||
// https://learn.microsoft.com/ja-jp/rest/api/storageservices/blob-service-error-codes
|
||||
if (!succeeded && errorCode !== 'ContainerNotFound') {
|
||||
throw new Error(
|
||||
`delete blob container failed. succeeded: ${succeeded}, errorCode: ${errorCode}, date: ${date}`,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.error(`error=${e}`);
|
||||
throw e;
|
||||
} finally {
|
||||
this.logger.log(
|
||||
`[OUT] [${context.trackingId}] ${this.deleteContainer.name}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Containers exists
|
||||
* @param country
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user