Azure / Azure/azure-libraries-for-java
Using ETag for better Create / Update experience
- Lenguaje dominante
- Java
- Estrellas
- 97
- Forks
- 102
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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 |
Guía de contribución
Línea de trabajo
Comienza siguiendo la ruta PUT de CreateOrUpdate utilizada por define().create() y update().apply(), y después revisa el comportamiento de ARM ETag descrito en el issue. Determina cómo deben aplicarse If-None-Match e If-Match, incluidas las respuestas 412 esperadas. Se considera completado cuando los recursos compatibles distinguen entre creación y actualización y conservan el comportamiento documentado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- azure, java
- Área
- api, backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100