Azure / Azure/azure-libraries-for-java

Using ETag for better Create / Update experience

Aperta
#866 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
ARM ARM - Tags feature-request Mgmt
Lingua principale
Java
Stelle
97
Fork
102
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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 |

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by tracing the CreateOrUpdate PUT path used by define().create() and update().apply(), then review the ARM ETag behavior described in the issue. Determine how If-None-Match and If-Match should be applied, including the expected 412 responses. Done means supported resources distinguish creation from update and preserve the documented behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
azure, java
Ambito
api, backend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.