
com.azure.resourcemanager.deviceupdate.implementation.AccountImpl Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.deviceupdate.implementation;
import com.azure.core.management.Region;
import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.deviceupdate.fluent.models.AccountInner;
import com.azure.resourcemanager.deviceupdate.fluent.models.PrivateEndpointConnectionInner;
import com.azure.resourcemanager.deviceupdate.models.Account;
import com.azure.resourcemanager.deviceupdate.models.AccountUpdate;
import com.azure.resourcemanager.deviceupdate.models.Encryption;
import com.azure.resourcemanager.deviceupdate.models.Location;
import com.azure.resourcemanager.deviceupdate.models.ManagedServiceIdentity;
import com.azure.resourcemanager.deviceupdate.models.PrivateEndpointConnection;
import com.azure.resourcemanager.deviceupdate.models.ProvisioningState;
import com.azure.resourcemanager.deviceupdate.models.PublicNetworkAccess;
import com.azure.resourcemanager.deviceupdate.models.Sku;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public final class AccountImpl implements Account, Account.Definition, Account.Update {
private AccountInner innerObject;
private final com.azure.resourcemanager.deviceupdate.DeviceUpdateManager 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 ManagedServiceIdentity identity() {
return this.innerModel().identity();
}
public SystemData systemData() {
return this.innerModel().systemData();
}
public ProvisioningState provisioningState() {
return this.innerModel().provisioningState();
}
public String hostname() {
return this.innerModel().hostname();
}
public PublicNetworkAccess publicNetworkAccess() {
return this.innerModel().publicNetworkAccess();
}
public List privateEndpointConnections() {
List inner = this.innerModel().privateEndpointConnections();
if (inner != null) {
return Collections.unmodifiableList(inner.stream()
.map(inner1 -> new PrivateEndpointConnectionImpl(inner1, this.manager()))
.collect(Collectors.toList()));
} else {
return Collections.emptyList();
}
}
public Sku sku() {
return this.innerModel().sku();
}
public Encryption encryption() {
return this.innerModel().encryption();
}
public List locations() {
List inner = this.innerModel().locations();
if (inner != null) {
return Collections.unmodifiableList(inner);
} else {
return Collections.emptyList();
}
}
public Region region() {
return Region.fromName(this.regionName());
}
public String regionName() {
return this.location();
}
public String resourceGroupName() {
return resourceGroupName;
}
public AccountInner innerModel() {
return this.innerObject;
}
private com.azure.resourcemanager.deviceupdate.DeviceUpdateManager manager() {
return this.serviceManager;
}
private String resourceGroupName;
private String accountName;
private AccountUpdate updateAccountUpdatePayload;
public AccountImpl withExistingResourceGroup(String resourceGroupName) {
this.resourceGroupName = resourceGroupName;
return this;
}
public Account create() {
this.innerObject = serviceManager.serviceClient()
.getAccounts()
.create(resourceGroupName, accountName, this.innerModel(), Context.NONE);
return this;
}
public Account create(Context context) {
this.innerObject = serviceManager.serviceClient()
.getAccounts()
.create(resourceGroupName, accountName, this.innerModel(), context);
return this;
}
AccountImpl(String name, com.azure.resourcemanager.deviceupdate.DeviceUpdateManager serviceManager) {
this.innerObject = new AccountInner();
this.serviceManager = serviceManager;
this.accountName = name;
}
public AccountImpl update() {
this.updateAccountUpdatePayload = new AccountUpdate();
return this;
}
public Account apply() {
this.innerObject = serviceManager.serviceClient()
.getAccounts()
.update(resourceGroupName, accountName, updateAccountUpdatePayload, Context.NONE);
return this;
}
public Account apply(Context context) {
this.innerObject = serviceManager.serviceClient()
.getAccounts()
.update(resourceGroupName, accountName, updateAccountUpdatePayload, context);
return this;
}
AccountImpl(AccountInner innerObject, com.azure.resourcemanager.deviceupdate.DeviceUpdateManager serviceManager) {
this.innerObject = innerObject;
this.serviceManager = serviceManager;
this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
this.accountName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "accounts");
}
public Account refresh() {
this.innerObject = serviceManager.serviceClient()
.getAccounts()
.getByResourceGroupWithResponse(resourceGroupName, accountName, Context.NONE)
.getValue();
return this;
}
public Account refresh(Context context) {
this.innerObject = serviceManager.serviceClient()
.getAccounts()
.getByResourceGroupWithResponse(resourceGroupName, accountName, context)
.getValue();
return this;
}
public AccountImpl withRegion(Region location) {
this.innerModel().withLocation(location.toString());
return this;
}
public AccountImpl withRegion(String location) {
this.innerModel().withLocation(location);
return this;
}
public AccountImpl withTags(Map tags) {
if (isInCreateMode()) {
this.innerModel().withTags(tags);
return this;
} else {
this.updateAccountUpdatePayload.withTags(tags);
return this;
}
}
public AccountImpl withIdentity(ManagedServiceIdentity identity) {
if (isInCreateMode()) {
this.innerModel().withIdentity(identity);
return this;
} else {
this.updateAccountUpdatePayload.withIdentity(identity);
return this;
}
}
public AccountImpl withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) {
this.innerModel().withPublicNetworkAccess(publicNetworkAccess);
return this;
}
public AccountImpl withPrivateEndpointConnections(List privateEndpointConnections) {
this.innerModel().withPrivateEndpointConnections(privateEndpointConnections);
return this;
}
public AccountImpl withSku(Sku sku) {
this.innerModel().withSku(sku);
return this;
}
public AccountImpl withEncryption(Encryption encryption) {
this.innerModel().withEncryption(encryption);
return this;
}
private boolean isInCreateMode() {
return this.innerModel().id() == null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy