com.azure.resourcemanager.dnsresolver.implementation.DnsResolverPolicyImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-dnsresolver Show documentation
Show all versions of azure-resourcemanager-dnsresolver Show documentation
This package contains Microsoft Azure SDK for DnsResolver Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The DNS Resolver Management Client. Package tag package-2022-07.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.dnsresolver.implementation;
import com.azure.core.management.Region;
import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.dnsresolver.fluent.models.DnsResolverPolicyInner;
import com.azure.resourcemanager.dnsresolver.models.DnsResolverPolicy;
import com.azure.resourcemanager.dnsresolver.models.DnsResolverPolicyPatch;
import com.azure.resourcemanager.dnsresolver.models.ProvisioningState;
import java.util.Collections;
import java.util.Map;
public final class DnsResolverPolicyImpl
implements DnsResolverPolicy, DnsResolverPolicy.Definition, DnsResolverPolicy.Update {
private DnsResolverPolicyInner innerObject;
private final com.azure.resourcemanager.dnsresolver.DnsResolverManager serviceManager;
public String id() {
return this.innerModel().id();
}
public String name() {
return this.innerModel().name();
}
public String type() {
return this.innerModel().type();
}
public String location() {
return this.innerModel().location();
}
public Map tags() {
Map inner = this.innerModel().tags();
if (inner != null) {
return Collections.unmodifiableMap(inner);
} else {
return Collections.emptyMap();
}
}
public String etag() {
return this.innerModel().etag();
}
public SystemData systemData() {
return this.innerModel().systemData();
}
public ProvisioningState provisioningState() {
return this.innerModel().provisioningState();
}
public String resourceGuid() {
return this.innerModel().resourceGuid();
}
public Region region() {
return Region.fromName(this.regionName());
}
public String regionName() {
return this.location();
}
public String resourceGroupName() {
return resourceGroupName;
}
public DnsResolverPolicyInner innerModel() {
return this.innerObject;
}
private com.azure.resourcemanager.dnsresolver.DnsResolverManager manager() {
return this.serviceManager;
}
private String resourceGroupName;
private String dnsResolverPolicyName;
private String createIfMatch;
private String createIfNoneMatch;
private String updateIfMatch;
private DnsResolverPolicyPatch updateParameters;
public DnsResolverPolicyImpl withExistingResourceGroup(String resourceGroupName) {
this.resourceGroupName = resourceGroupName;
return this;
}
public DnsResolverPolicy create() {
this.innerObject = serviceManager.serviceClient()
.getDnsResolverPolicies()
.createOrUpdate(resourceGroupName, dnsResolverPolicyName, this.innerModel(), createIfMatch,
createIfNoneMatch, Context.NONE);
return this;
}
public DnsResolverPolicy create(Context context) {
this.innerObject = serviceManager.serviceClient()
.getDnsResolverPolicies()
.createOrUpdate(resourceGroupName, dnsResolverPolicyName, this.innerModel(), createIfMatch,
createIfNoneMatch, context);
return this;
}
DnsResolverPolicyImpl(String name, com.azure.resourcemanager.dnsresolver.DnsResolverManager serviceManager) {
this.innerObject = new DnsResolverPolicyInner();
this.serviceManager = serviceManager;
this.dnsResolverPolicyName = name;
this.createIfMatch = null;
this.createIfNoneMatch = null;
}
public DnsResolverPolicyImpl update() {
this.updateIfMatch = null;
this.updateParameters = new DnsResolverPolicyPatch();
return this;
}
public DnsResolverPolicy apply() {
this.innerObject = serviceManager.serviceClient()
.getDnsResolverPolicies()
.update(resourceGroupName, dnsResolverPolicyName, updateParameters, updateIfMatch, Context.NONE);
return this;
}
public DnsResolverPolicy apply(Context context) {
this.innerObject = serviceManager.serviceClient()
.getDnsResolverPolicies()
.update(resourceGroupName, dnsResolverPolicyName, updateParameters, updateIfMatch, context);
return this;
}
DnsResolverPolicyImpl(DnsResolverPolicyInner innerObject,
com.azure.resourcemanager.dnsresolver.DnsResolverManager serviceManager) {
this.innerObject = innerObject;
this.serviceManager = serviceManager;
this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
this.dnsResolverPolicyName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "dnsResolverPolicies");
}
public DnsResolverPolicy refresh() {
this.innerObject = serviceManager.serviceClient()
.getDnsResolverPolicies()
.getByResourceGroupWithResponse(resourceGroupName, dnsResolverPolicyName, Context.NONE)
.getValue();
return this;
}
public DnsResolverPolicy refresh(Context context) {
this.innerObject = serviceManager.serviceClient()
.getDnsResolverPolicies()
.getByResourceGroupWithResponse(resourceGroupName, dnsResolverPolicyName, context)
.getValue();
return this;
}
public DnsResolverPolicyImpl withRegion(Region location) {
this.innerModel().withLocation(location.toString());
return this;
}
public DnsResolverPolicyImpl withRegion(String location) {
this.innerModel().withLocation(location);
return this;
}
public DnsResolverPolicyImpl withTags(Map tags) {
if (isInCreateMode()) {
this.innerModel().withTags(tags);
return this;
} else {
this.updateParameters.withTags(tags);
return this;
}
}
public DnsResolverPolicyImpl withIfMatch(String ifMatch) {
if (isInCreateMode()) {
this.createIfMatch = ifMatch;
return this;
} else {
this.updateIfMatch = ifMatch;
return this;
}
}
public DnsResolverPolicyImpl withIfNoneMatch(String ifNoneMatch) {
this.createIfNoneMatch = ifNoneMatch;
return this;
}
private boolean isInCreateMode() {
return this.innerModel().id() == null;
}
}