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

com.microsoft.azure.PolicyViolation Maven / Gradle / Ivy

Go to download

This package contains the basic runtime for AutoRest generated Azure Java clients.

The newest version!
/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 */

package com.microsoft.azure;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
 * An instance of this class provides Azure policy violation information.
 */
public class PolicyViolation extends TypedErrorInfo {
    /**
     * Policy violation error details.
     */
    private PolicyViolationErrorInfo policyErrorInfo;

    /**
     * Initializes a new instance of PolicyViolation.
     *
     * @param type            the error type
     * @param policyErrorInfo the error details
     * @throws JsonParseException   if the policyErrorInfo has invalid content.
     * @throws JsonMappingException if the policyErrorInfo's JSON does not match the expected schema.
     * @throws IOException          if an IO error occurs.
     */
    public PolicyViolation(String type, ObjectNode policyErrorInfo) throws JsonParseException, JsonMappingException, IOException {
        super(type, policyErrorInfo);
        ObjectMapper objectMapper = new ObjectMapper()
                .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
                .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        this.policyErrorInfo = objectMapper.readValue(policyErrorInfo.toString(), PolicyViolationErrorInfo.class);
    }

    /**
     * @return the policy violation error details.
     */
    public PolicyViolationErrorInfo policyErrorInfo() {
        return policyErrorInfo;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy