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

com.azure.resourcemanager.securityinsights.models.RepositoryResourceInfo Maven / Gradle / Ivy

Go to download

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

The 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.securityinsights.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * Resources created in user's repository for the source-control.
 */
@Fluent
public final class RepositoryResourceInfo implements JsonSerializable {
    /*
     * The webhook object created for the source-control.
     */
    private Webhook webhook;

    /*
     * Resources created in GitHub for this source-control.
     */
    private GitHubResourceInfo gitHubResourceInfo;

    /*
     * Resources created in Azure DevOps for this source-control.
     */
    private AzureDevOpsResourceInfo azureDevOpsResourceInfo;

    /**
     * Creates an instance of RepositoryResourceInfo class.
     */
    public RepositoryResourceInfo() {
    }

    /**
     * Get the webhook property: The webhook object created for the source-control.
     * 
     * @return the webhook value.
     */
    public Webhook webhook() {
        return this.webhook;
    }

    /**
     * Set the webhook property: The webhook object created for the source-control.
     * 
     * @param webhook the webhook value to set.
     * @return the RepositoryResourceInfo object itself.
     */
    public RepositoryResourceInfo withWebhook(Webhook webhook) {
        this.webhook = webhook;
        return this;
    }

    /**
     * Get the gitHubResourceInfo property: Resources created in GitHub for this source-control.
     * 
     * @return the gitHubResourceInfo value.
     */
    public GitHubResourceInfo gitHubResourceInfo() {
        return this.gitHubResourceInfo;
    }

    /**
     * Set the gitHubResourceInfo property: Resources created in GitHub for this source-control.
     * 
     * @param gitHubResourceInfo the gitHubResourceInfo value to set.
     * @return the RepositoryResourceInfo object itself.
     */
    public RepositoryResourceInfo withGitHubResourceInfo(GitHubResourceInfo gitHubResourceInfo) {
        this.gitHubResourceInfo = gitHubResourceInfo;
        return this;
    }

    /**
     * Get the azureDevOpsResourceInfo property: Resources created in Azure DevOps for this source-control.
     * 
     * @return the azureDevOpsResourceInfo value.
     */
    public AzureDevOpsResourceInfo azureDevOpsResourceInfo() {
        return this.azureDevOpsResourceInfo;
    }

    /**
     * Set the azureDevOpsResourceInfo property: Resources created in Azure DevOps for this source-control.
     * 
     * @param azureDevOpsResourceInfo the azureDevOpsResourceInfo value to set.
     * @return the RepositoryResourceInfo object itself.
     */
    public RepositoryResourceInfo withAzureDevOpsResourceInfo(AzureDevOpsResourceInfo azureDevOpsResourceInfo) {
        this.azureDevOpsResourceInfo = azureDevOpsResourceInfo;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (webhook() != null) {
            webhook().validate();
        }
        if (gitHubResourceInfo() != null) {
            gitHubResourceInfo().validate();
        }
        if (azureDevOpsResourceInfo() != null) {
            azureDevOpsResourceInfo().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("webhook", this.webhook);
        jsonWriter.writeJsonField("gitHubResourceInfo", this.gitHubResourceInfo);
        jsonWriter.writeJsonField("azureDevOpsResourceInfo", this.azureDevOpsResourceInfo);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of RepositoryResourceInfo from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of RepositoryResourceInfo if the JsonReader was pointing to an instance of it, or null if it
     * was pointing to JSON null.
     * @throws IOException If an error occurs while reading the RepositoryResourceInfo.
     */
    public static RepositoryResourceInfo fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            RepositoryResourceInfo deserializedRepositoryResourceInfo = new RepositoryResourceInfo();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("webhook".equals(fieldName)) {
                    deserializedRepositoryResourceInfo.webhook = Webhook.fromJson(reader);
                } else if ("gitHubResourceInfo".equals(fieldName)) {
                    deserializedRepositoryResourceInfo.gitHubResourceInfo = GitHubResourceInfo.fromJson(reader);
                } else if ("azureDevOpsResourceInfo".equals(fieldName)) {
                    deserializedRepositoryResourceInfo.azureDevOpsResourceInfo
                        = AzureDevOpsResourceInfo.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRepositoryResourceInfo;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy