All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.security.implementation.JitNetworkAccessPolicyImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Security Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.Security (Azure Security Center) resource provider. Package tag package-composite-v3.

There is a newer version: 1.0.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.security.implementation;

import com.azure.core.management.Region;
import com.azure.core.util.Context;
import com.azure.resourcemanager.security.fluent.models.JitNetworkAccessPolicyInner;
import com.azure.resourcemanager.security.fluent.models.JitNetworkAccessRequestInner;
import com.azure.resourcemanager.security.models.JitNetworkAccessPolicy;
import com.azure.resourcemanager.security.models.JitNetworkAccessPolicyVirtualMachine;
import com.azure.resourcemanager.security.models.JitNetworkAccessRequest;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public final class JitNetworkAccessPolicyImpl
    implements JitNetworkAccessPolicy, JitNetworkAccessPolicy.Definition, JitNetworkAccessPolicy.Update {
    private JitNetworkAccessPolicyInner innerObject;

    private final com.azure.resourcemanager.security.SecurityManager serviceManager;

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public String kind() {
        return this.innerModel().kind();
    }

    public String location() {
        return this.innerModel().location();
    }

    public List virtualMachines() {
        List inner = this.innerModel().virtualMachines();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public List requests() {
        List inner = this.innerModel().requests();
        if (inner != null) {
            return Collections.unmodifiableList(inner.stream()
                .map(inner1 -> new JitNetworkAccessRequestImpl(inner1, this.manager()))
                .collect(Collectors.toList()));
        } else {
            return Collections.emptyList();
        }
    }

    public String provisioningState() {
        return this.innerModel().provisioningState();
    }

    public Region region() {
        return Region.fromName(this.regionName());
    }

    public String regionName() {
        return this.location();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

    public JitNetworkAccessPolicyInner innerModel() {
        return this.innerObject;
    }

    private com.azure.resourcemanager.security.SecurityManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String ascLocation;

    private String jitNetworkAccessPolicyName;

    public JitNetworkAccessPolicyImpl withExistingLocation(String resourceGroupName, String ascLocation) {
        this.resourceGroupName = resourceGroupName;
        this.ascLocation = ascLocation;
        return this;
    }

    public JitNetworkAccessPolicy create() {
        this.innerObject = serviceManager.serviceClient()
            .getJitNetworkAccessPolicies()
            .createOrUpdateWithResponse(resourceGroupName, ascLocation, jitNetworkAccessPolicyName, this.innerModel(),
                Context.NONE)
            .getValue();
        return this;
    }

    public JitNetworkAccessPolicy create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getJitNetworkAccessPolicies()
            .createOrUpdateWithResponse(resourceGroupName, ascLocation, jitNetworkAccessPolicyName, this.innerModel(),
                context)
            .getValue();
        return this;
    }

    JitNetworkAccessPolicyImpl(String name, com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = new JitNetworkAccessPolicyInner();
        this.serviceManager = serviceManager;
        this.jitNetworkAccessPolicyName = name;
    }

    public JitNetworkAccessPolicyImpl update() {
        return this;
    }

    public JitNetworkAccessPolicy apply() {
        this.innerObject = serviceManager.serviceClient()
            .getJitNetworkAccessPolicies()
            .createOrUpdateWithResponse(resourceGroupName, ascLocation, jitNetworkAccessPolicyName, this.innerModel(),
                Context.NONE)
            .getValue();
        return this;
    }

    public JitNetworkAccessPolicy apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getJitNetworkAccessPolicies()
            .createOrUpdateWithResponse(resourceGroupName, ascLocation, jitNetworkAccessPolicyName, this.innerModel(),
                context)
            .getValue();
        return this;
    }

    JitNetworkAccessPolicyImpl(JitNetworkAccessPolicyInner innerObject,
        com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.ascLocation = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "locations");
        this.jitNetworkAccessPolicyName
            = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "jitNetworkAccessPolicies");
    }

    public JitNetworkAccessPolicy refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getJitNetworkAccessPolicies()
            .getWithResponse(resourceGroupName, ascLocation, jitNetworkAccessPolicyName, Context.NONE)
            .getValue();
        return this;
    }

    public JitNetworkAccessPolicy refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getJitNetworkAccessPolicies()
            .getWithResponse(resourceGroupName, ascLocation, jitNetworkAccessPolicyName, context)
            .getValue();
        return this;
    }

    public JitNetworkAccessPolicyImpl withVirtualMachines(List virtualMachines) {
        this.innerModel().withVirtualMachines(virtualMachines);
        return this;
    }

    public JitNetworkAccessPolicyImpl withKind(String kind) {
        this.innerModel().withKind(kind);
        return this;
    }

    public JitNetworkAccessPolicyImpl withRequests(List requests) {
        this.innerModel().withRequests(requests);
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy