Azure / Azure/azure-libraries-for-java

Using ETag for better Create / Update experience

オープン
#866 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
ARM ARM - Tags feature-request Mgmt
主要言語
Java
スター
97
フォーク
102
PR マージ指標
30日以内にマージされた PR はありません

説明

Today the `CreateOrUpdate` (PUT) semantic make it difficult to distinguish between Creation and Update of a resource. For example consider user trying to create a new resource group:

```java
ResourceGroup resourceGroup = azure.resourceGroups()
.define("myRG")
.withRegion(Region.US_EAST)
.withTag("aa", "bb")
.create();
```

If the resource group with name "MyRG" already exists user will be expecting an error, but this call still succeeded since we don't have a way to tell server that create it if not exist and fail it already exists.

As per ARM spec, a resource provider can can optionally support ETag specific headers (If-Match, If-None-Match) , if they do then SDK can make use of this header with `CreateOrUpdate` (PUT) calls and provide better experience to the user.

```
define()..create() -> CreateOrUpdate + If-None-Match = "*"
With this, if resource already exits PUT will fail with error code 412
update()..apply() -> CreateOrUpdate + If-Match = "*"
With this, if resource does not exists PUT will fail with error code 412
```

| PUT | Resource does not exist | Resource exists |
| ------------- |:-------------:| -----:|
| If-Match = "" / absent | 201 Created | 200 OK |
| If-Match = "*" | 412 Precondition Failed | 200 OK |
| If-Match = "xyz" | 412 Precondition Failed | 200 OK / 412 Precondition Failed |
| If-None-Match = "*" | 201 Created | 412 Precondition Failed |

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、define().create() と update().apply() で使用される CreateOrUpdate PUT パスを追跡し、次に issue に記載された ARM ETag の動作を確認します。If-None-Match と If-Match をどのように適用すべきかを、想定される 412 レスポンスも含めて判断します。サポート対象のリソースが作成と更新を区別し、文書化された動作を維持すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, java
領域
api, backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。