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

com.azure.resourcemanager.security.implementation.InformationProtectionPolicyImpl 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.security.implementation;

import com.azure.core.util.Context;
import com.azure.resourcemanager.security.fluent.models.InformationProtectionPolicyInner;
import com.azure.resourcemanager.security.models.InformationProtectionPolicy;
import com.azure.resourcemanager.security.models.InformationProtectionPolicyName;
import com.azure.resourcemanager.security.models.InformationType;
import com.azure.resourcemanager.security.models.SensitivityLabel;
import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.Map;

public final class InformationProtectionPolicyImpl
    implements InformationProtectionPolicy, InformationProtectionPolicy.Definition, InformationProtectionPolicy.Update {
    private InformationProtectionPolicyInner 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 OffsetDateTime lastModifiedUtc() {
        return this.innerModel().lastModifiedUtc();
    }

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

    public Map labels() {
        Map inner = this.innerModel().labels();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    public Map informationTypes() {
        Map inner = this.innerModel().informationTypes();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

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

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

    private String scope;

    private InformationProtectionPolicyName informationProtectionPolicyName;

    public InformationProtectionPolicyImpl withExistingScope(String scope) {
        this.scope = scope;
        return this;
    }

    public InformationProtectionPolicy create() {
        this.innerObject = serviceManager.serviceClient()
            .getInformationProtectionPolicies()
            .createOrUpdateWithResponse(scope, informationProtectionPolicyName, this.innerModel(), Context.NONE)
            .getValue();
        return this;
    }

    public InformationProtectionPolicy create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getInformationProtectionPolicies()
            .createOrUpdateWithResponse(scope, informationProtectionPolicyName, this.innerModel(), context)
            .getValue();
        return this;
    }

    InformationProtectionPolicyImpl(InformationProtectionPolicyName name,
        com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = new InformationProtectionPolicyInner();
        this.serviceManager = serviceManager;
        this.informationProtectionPolicyName = name;
    }

    public InformationProtectionPolicyImpl update() {
        return this;
    }

    public InformationProtectionPolicy apply() {
        this.innerObject = serviceManager.serviceClient()
            .getInformationProtectionPolicies()
            .createOrUpdateWithResponse(scope, informationProtectionPolicyName, this.innerModel(), Context.NONE)
            .getValue();
        return this;
    }

    public InformationProtectionPolicy apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getInformationProtectionPolicies()
            .createOrUpdateWithResponse(scope, informationProtectionPolicyName, this.innerModel(), context)
            .getValue();
        return this;
    }

    InformationProtectionPolicyImpl(InformationProtectionPolicyInner innerObject,
        com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.scope = ResourceManagerUtils.getValueFromIdByParameterName(innerObject.id(),
            "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}",
            "scope");
        this.informationProtectionPolicyName = InformationProtectionPolicyName
            .fromString(ResourceManagerUtils.getValueFromIdByParameterName(innerObject.id(),
                "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}",
                "informationProtectionPolicyName"));
    }

    public InformationProtectionPolicy refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getInformationProtectionPolicies()
            .getWithResponse(scope, informationProtectionPolicyName, Context.NONE)
            .getValue();
        return this;
    }

    public InformationProtectionPolicy refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getInformationProtectionPolicies()
            .getWithResponse(scope, informationProtectionPolicyName, context)
            .getValue();
        return this;
    }

    public InformationProtectionPolicyImpl withLabels(Map labels) {
        this.innerModel().withLabels(labels);
        return this;
    }

    public InformationProtectionPolicyImpl withInformationTypes(Map informationTypes) {
        this.innerModel().withInformationTypes(informationTypes);
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy