@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 boolean isInCreateMode() { return this.inner().id() == null; }
@Override protected ResourceGroupImpl wrapModel(String name) { return new ResourceGroupImpl( new ResourceGroupInner().withName(name), serviceClient); }
@Override public Map<String, String> tags() { Map<String, String> tags = this.inner().tags(); if (tags == null) { tags = new HashMap<>(); } return Collections.unmodifiableMap(tags); }
@Override public ResourceGroupImpl withTags(Map<String, String> tags) { this.inner().withTags(new HashMap<>(tags)); return this; }
protected ResourceGroupImpl(final ResourceGroupInner innerModel, final ResourceManagementClientImpl serviceClient) { super(innerModel.name(), innerModel); this.client = serviceClient.resourceGroups(); }
@Override public ResourceGroupImpl withRegion(String regionName) { this.inner().withLocation(regionName); return this; }
@Override public String provisioningState() { return this.inner().properties().provisioningState(); }
@Override public String regionName() { return this.inner().location(); }
@Override public ResourceGroupImpl withoutTag(String key) { this.inner().tags().remove(key); return this; }
@Override public ResourceGroupImpl withTags(Map<String, String> tags) { this.inner().withTags(new HashMap<>(tags)); return this; }
@Override public String name() { return this.inner().name(); }
@Override public ResourceGroupImpl withRegion(String regionName) { this.inner().withLocation(regionName); return this; }
@Override public String provisioningState() { return this.inner().properties().provisioningState(); }
@Override public String regionName() { return this.inner().location(); }
@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 Map<String, String> tags() { Map<String, String> tags = this.inner().tags(); if (tags == null) { tags = new HashMap<>(); } return Collections.unmodifiableMap(tags); }