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

com.azure.resourcemanager.mediaservices.implementation.StreamingEndpointsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for MediaServices Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. This Swagger was generated by the API Framework. Package tag package-account-2023-01.

There is a newer version: 2.4.0-beta.2
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.mediaservices.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.mediaservices.fluent.StreamingEndpointsClient;
import com.azure.resourcemanager.mediaservices.fluent.models.StreamingEndpointInner;
import com.azure.resourcemanager.mediaservices.fluent.models.StreamingEndpointSkuInfoListResultInner;
import com.azure.resourcemanager.mediaservices.models.StreamingEndpoint;
import com.azure.resourcemanager.mediaservices.models.StreamingEndpointSkuInfoListResult;
import com.azure.resourcemanager.mediaservices.models.StreamingEndpoints;
import com.azure.resourcemanager.mediaservices.models.StreamingEntityScaleUnit;

public final class StreamingEndpointsImpl implements StreamingEndpoints {
    private static final ClientLogger LOGGER = new ClientLogger(StreamingEndpointsImpl.class);

    private final StreamingEndpointsClient innerClient;

    private final com.azure.resourcemanager.mediaservices.MediaServicesManager serviceManager;

    public StreamingEndpointsImpl(
        StreamingEndpointsClient innerClient,
        com.azure.resourcemanager.mediaservices.MediaServicesManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable list(String resourceGroupName, String accountName) {
        PagedIterable inner = this.serviceClient().list(resourceGroupName, accountName);
        return Utils.mapPage(inner, inner1 -> new StreamingEndpointImpl(inner1, this.manager()));
    }

    public PagedIterable list(String resourceGroupName, String accountName, Context context) {
        PagedIterable inner =
            this.serviceClient().list(resourceGroupName, accountName, context);
        return Utils.mapPage(inner, inner1 -> new StreamingEndpointImpl(inner1, this.manager()));
    }

    public StreamingEndpoint get(String resourceGroupName, String accountName, String streamingEndpointName) {
        StreamingEndpointInner inner = this.serviceClient().get(resourceGroupName, accountName, streamingEndpointName);
        if (inner != null) {
            return new StreamingEndpointImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public void delete(String resourceGroupName, String accountName, String streamingEndpointName) {
        this.serviceClient().delete(resourceGroupName, accountName, streamingEndpointName);
    }

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

    public StreamingEndpointSkuInfoListResult skus(
        String resourceGroupName, String accountName, String streamingEndpointName) {
        StreamingEndpointSkuInfoListResultInner inner =
            this.serviceClient().skus(resourceGroupName, accountName, streamingEndpointName);
        if (inner != null) {
            return new StreamingEndpointSkuInfoListResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public void start(String resourceGroupName, String accountName, String streamingEndpointName) {
        this.serviceClient().start(resourceGroupName, accountName, streamingEndpointName);
    }

    public void start(String resourceGroupName, String accountName, String streamingEndpointName, Context context) {
        this.serviceClient().start(resourceGroupName, accountName, streamingEndpointName, context);
    }

    public void stop(String resourceGroupName, String accountName, String streamingEndpointName) {
        this.serviceClient().stop(resourceGroupName, accountName, streamingEndpointName);
    }

    public void stop(String resourceGroupName, String accountName, String streamingEndpointName, Context context) {
        this.serviceClient().stop(resourceGroupName, accountName, streamingEndpointName, context);
    }

    public void scale(
        String resourceGroupName,
        String accountName,
        String streamingEndpointName,
        StreamingEntityScaleUnit parameters) {
        this.serviceClient().scale(resourceGroupName, accountName, streamingEndpointName, parameters);
    }

    public void scale(
        String resourceGroupName,
        String accountName,
        String streamingEndpointName,
        StreamingEntityScaleUnit parameters,
        Context context) {
        this.serviceClient().scale(resourceGroupName, accountName, streamingEndpointName, parameters, context);
    }

    public StreamingEndpoint getById(String id) {
        String resourceGroupName = Utils.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 accountName = Utils.getValueFromIdByName(id, "mediaservices");
        if (accountName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String.format("The resource ID '%s' is not valid. Missing path segment 'mediaservices'.", id)));
        }
        String streamingEndpointName = Utils.getValueFromIdByName(id, "streamingEndpoints");
        if (streamingEndpointName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String
                            .format(
                                "The resource ID '%s' is not valid. Missing path segment 'streamingEndpoints'.", id)));
        }
        return this.getWithResponse(resourceGroupName, accountName, streamingEndpointName, Context.NONE).getValue();
    }

    public Response getByIdWithResponse(String id, Context context) {
        String resourceGroupName = Utils.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 accountName = Utils.getValueFromIdByName(id, "mediaservices");
        if (accountName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String.format("The resource ID '%s' is not valid. Missing path segment 'mediaservices'.", id)));
        }
        String streamingEndpointName = Utils.getValueFromIdByName(id, "streamingEndpoints");
        if (streamingEndpointName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String
                            .format(
                                "The resource ID '%s' is not valid. Missing path segment 'streamingEndpoints'.", id)));
        }
        return this.getWithResponse(resourceGroupName, accountName, streamingEndpointName, context);
    }

    public void deleteById(String id) {
        String resourceGroupName = Utils.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 accountName = Utils.getValueFromIdByName(id, "mediaservices");
        if (accountName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String.format("The resource ID '%s' is not valid. Missing path segment 'mediaservices'.", id)));
        }
        String streamingEndpointName = Utils.getValueFromIdByName(id, "streamingEndpoints");
        if (streamingEndpointName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String
                            .format(
                                "The resource ID '%s' is not valid. Missing path segment 'streamingEndpoints'.", id)));
        }
        this.delete(resourceGroupName, accountName, streamingEndpointName, Context.NONE);
    }

    public void deleteByIdWithResponse(String id, Context context) {
        String resourceGroupName = Utils.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 accountName = Utils.getValueFromIdByName(id, "mediaservices");
        if (accountName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String.format("The resource ID '%s' is not valid. Missing path segment 'mediaservices'.", id)));
        }
        String streamingEndpointName = Utils.getValueFromIdByName(id, "streamingEndpoints");
        if (streamingEndpointName == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        String
                            .format(
                                "The resource ID '%s' is not valid. Missing path segment 'streamingEndpoints'.", id)));
        }
        this.delete(resourceGroupName, accountName, streamingEndpointName, context);
    }

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

    private com.azure.resourcemanager.mediaservices.MediaServicesManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy