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

com.azure.resourcemanager.logz.implementation.MonitorsImpl 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.logz.implementation;

import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.logz.fluent.MonitorsClient;
import com.azure.resourcemanager.logz.fluent.models.LogzMonitorResourceInner;
import com.azure.resourcemanager.logz.fluent.models.MonitoredResourceInner;
import com.azure.resourcemanager.logz.fluent.models.UserRoleResponseInner;
import com.azure.resourcemanager.logz.models.LogzMonitorResource;
import com.azure.resourcemanager.logz.models.MonitoredResource;
import com.azure.resourcemanager.logz.models.Monitors;
import com.azure.resourcemanager.logz.models.UserRoleRequest;
import com.azure.resourcemanager.logz.models.UserRoleResponse;

public final class MonitorsImpl implements Monitors {
    private static final ClientLogger LOGGER = new ClientLogger(MonitorsImpl.class);

    private final MonitorsClient innerClient;

    private final com.azure.resourcemanager.logz.LogzManager serviceManager;

    public MonitorsImpl(MonitorsClient innerClient, com.azure.resourcemanager.logz.LogzManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable listMonitoredResources(String resourceGroupName, String monitorName) {
        PagedIterable inner
            = this.serviceClient().listMonitoredResources(resourceGroupName, monitorName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new MonitoredResourceImpl(inner1, this.manager()));
    }

    public PagedIterable listMonitoredResources(String resourceGroupName, String monitorName,
        Context context) {
        PagedIterable inner
            = this.serviceClient().listMonitoredResources(resourceGroupName, monitorName, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new MonitoredResourceImpl(inner1, this.manager()));
    }

    public PagedIterable list() {
        PagedIterable inner = this.serviceClient().list();
        return ResourceManagerUtils.mapPage(inner, inner1 -> new LogzMonitorResourceImpl(inner1, this.manager()));
    }

    public PagedIterable list(Context context) {
        PagedIterable inner = this.serviceClient().list(context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new LogzMonitorResourceImpl(inner1, this.manager()));
    }

    public PagedIterable listByResourceGroup(String resourceGroupName) {
        PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new LogzMonitorResourceImpl(inner1, this.manager()));
    }

    public PagedIterable listByResourceGroup(String resourceGroupName, Context context) {
        PagedIterable inner
            = this.serviceClient().listByResourceGroup(resourceGroupName, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new LogzMonitorResourceImpl(inner1, this.manager()));
    }

    public Response getByResourceGroupWithResponse(String resourceGroupName, String monitorName,
        Context context) {
        Response inner
            = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, monitorName, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new LogzMonitorResourceImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public LogzMonitorResource getByResourceGroup(String resourceGroupName, String monitorName) {
        LogzMonitorResourceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, monitorName);
        if (inner != null) {
            return new LogzMonitorResourceImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public void deleteByResourceGroup(String resourceGroupName, String monitorName) {
        this.serviceClient().delete(resourceGroupName, monitorName);
    }

    public void delete(String resourceGroupName, String monitorName, Context context) {
        this.serviceClient().delete(resourceGroupName, monitorName, context);
    }

    public PagedIterable listUserRoles(String resourceGroupName, String monitorName) {
        PagedIterable inner = this.serviceClient().listUserRoles(resourceGroupName, monitorName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new UserRoleResponseImpl(inner1, this.manager()));
    }

    public PagedIterable listUserRoles(String resourceGroupName, String monitorName,
        UserRoleRequest body, Context context) {
        PagedIterable inner
            = this.serviceClient().listUserRoles(resourceGroupName, monitorName, body, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new UserRoleResponseImpl(inner1, this.manager()));
    }

    public LogzMonitorResource getById(String id) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String monitorName = ResourceManagerUtils.getValueFromIdByName(id, "monitors");
        if (monitorName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'monitors'.", id)));
        }
        return this.getByResourceGroupWithResponse(resourceGroupName, monitorName, Context.NONE).getValue();
    }

    public Response getByIdWithResponse(String id, Context context) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String monitorName = ResourceManagerUtils.getValueFromIdByName(id, "monitors");
        if (monitorName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'monitors'.", id)));
        }
        return this.getByResourceGroupWithResponse(resourceGroupName, monitorName, context);
    }

    public void deleteById(String id) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String monitorName = ResourceManagerUtils.getValueFromIdByName(id, "monitors");
        if (monitorName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'monitors'.", id)));
        }
        this.delete(resourceGroupName, monitorName, Context.NONE);
    }

    public void deleteByIdWithResponse(String id, Context context) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String monitorName = ResourceManagerUtils.getValueFromIdByName(id, "monitors");
        if (monitorName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'monitors'.", id)));
        }
        this.delete(resourceGroupName, monitorName, context);
    }

    private MonitorsClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.logz.LogzManager manager() {
        return this.serviceManager;
    }

    public LogzMonitorResourceImpl define(String name) {
        return new LogzMonitorResourceImpl(name, this.manager());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy