@Override public ResourceGroupImpl withTags(Map<String, String> tags) { this.inner().withTags(new HashMap<>(tags)); return this; }
@Override public ResourceGroupImpl withTags(Map<String, String> tags) { this.inner().withTags(new HashMap<>(tags)); return this; }
@Override public ResourceGroupImpl withTag(String key, String value) { if (this.inner().tags() == null) { this.inner().withTags(new HashMap<String, String>()); } this.inner().tags().put(key, value); return this; }
@Override public ResourceGroupImpl withTag(String key, String value) { if (this.inner().tags() == null) { this.inner().withTags(new HashMap<String, String>()); } this.inner().tags().put(key, value); return this; }
@Override public Observable<ResourceGroup> createResourceAsync() { ResourceGroupInner params = new ResourceGroupInner(); params.withLocation(this.inner().location()); params.withTags(this.inner().tags()); return client.createOrUpdateAsync(this.name(), params) .map(innerToFluentMap(this)); }
@Override public Response intercept(Chain chain) throws IOException { if ("PUT".equals(chain.request().method()) && chain.request().url().uri().toString().contains("/resourcegroups/") && LOGGING_CONTEXT.equals(chain.request().header("x-ms-logging-context"))) { String body = bodyToString(chain.request()); ResourceGroupInner rg = adapter.deserialize(body, ResourceGroupInner.class); if (rg == null) { throw new RuntimeException("Failed to deserialize " + body); } Map<String, String> tags = rg.tags(); if (tags == null) { tags = new HashMap<>(); } tags.put("product", "javasdk"); tags.put("cause", "automation"); tags.put("date", DateTime.now(DateTimeZone.UTC).toString()); if (System.getenv("ENV_JOB_NAME") != null) { tags.put("job", System.getenv("ENV_JOB_NAME")); } rg.withTags(tags); String newBody = adapter.serialize(rg); Request newRequest = chain.request().newBuilder() .put(RequestBody.create(chain.request().body().contentType(), newBody)) .header("Content-Length", String.valueOf(newBody.length())).build(); return chain.proceed(newRequest); } return chain.proceed(chain.request()); }
@Override public Observable<ResourceGroup> createResourceAsync() { ResourceGroupInner params = new ResourceGroupInner(); params.withLocation(this.inner().location()); params.withTags(this.inner().tags()); return client.createOrUpdateAsync(this.name(), params) .map(innerToFluentMap(this)); }