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

com.azure.resourcemanager.mediaservices.implementation.TracksImpl 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.

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.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.TracksClient;
import com.azure.resourcemanager.mediaservices.fluent.models.AssetTrackInner;
import com.azure.resourcemanager.mediaservices.models.AssetTrack;
import com.azure.resourcemanager.mediaservices.models.Tracks;

public final class TracksImpl implements Tracks {
    private static final ClientLogger LOGGER = new ClientLogger(TracksImpl.class);

    private final TracksClient innerClient;

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

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

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

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

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

    public AssetTrack get(String resourceGroupName, String accountName, String assetName, String trackName) {
        AssetTrackInner inner = this.serviceClient().get(resourceGroupName, accountName, assetName, trackName);
        if (inner != null) {
            return new AssetTrackImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

    public void updateTrackData(String resourceGroupName, String accountName, String assetName, String trackName) {
        this.serviceClient().updateTrackData(resourceGroupName, accountName, assetName, trackName);
    }

    public void updateTrackData(String resourceGroupName, String accountName, String assetName, String trackName,
        Context context) {
        this.serviceClient().updateTrackData(resourceGroupName, accountName, assetName, trackName, context);
    }

    public AssetTrack 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 accountName = ResourceManagerUtils.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 assetName = ResourceManagerUtils.getValueFromIdByName(id, "assets");
        if (assetName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'assets'.", id)));
        }
        String trackName = ResourceManagerUtils.getValueFromIdByName(id, "tracks");
        if (trackName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'tracks'.", id)));
        }
        return this.getWithResponse(resourceGroupName, accountName, assetName, trackName, 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 accountName = ResourceManagerUtils.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 assetName = ResourceManagerUtils.getValueFromIdByName(id, "assets");
        if (assetName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'assets'.", id)));
        }
        String trackName = ResourceManagerUtils.getValueFromIdByName(id, "tracks");
        if (trackName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'tracks'.", id)));
        }
        return this.getWithResponse(resourceGroupName, accountName, assetName, trackName, 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 accountName = ResourceManagerUtils.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 assetName = ResourceManagerUtils.getValueFromIdByName(id, "assets");
        if (assetName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'assets'.", id)));
        }
        String trackName = ResourceManagerUtils.getValueFromIdByName(id, "tracks");
        if (trackName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'tracks'.", id)));
        }
        this.delete(resourceGroupName, accountName, assetName, trackName, 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 accountName = ResourceManagerUtils.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 assetName = ResourceManagerUtils.getValueFromIdByName(id, "assets");
        if (assetName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'assets'.", id)));
        }
        String trackName = ResourceManagerUtils.getValueFromIdByName(id, "tracks");
        if (trackName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'tracks'.", id)));
        }
        this.delete(resourceGroupName, accountName, assetName, trackName, context);
    }

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy