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

com.azure.resourcemanager.orbital.implementation.SpacecraftsImpl 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.orbital.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.orbital.fluent.SpacecraftsClient;
import com.azure.resourcemanager.orbital.fluent.models.AvailableContactsInner;
import com.azure.resourcemanager.orbital.fluent.models.SpacecraftInner;
import com.azure.resourcemanager.orbital.models.AvailableContacts;
import com.azure.resourcemanager.orbital.models.ContactParameters;
import com.azure.resourcemanager.orbital.models.Spacecraft;
import com.azure.resourcemanager.orbital.models.Spacecrafts;

public final class SpacecraftsImpl implements Spacecrafts {
    private static final ClientLogger LOGGER = new ClientLogger(SpacecraftsImpl.class);

    private final SpacecraftsClient innerClient;

    private final com.azure.resourcemanager.orbital.OrbitalManager serviceManager;

    public SpacecraftsImpl(SpacecraftsClient innerClient,
        com.azure.resourcemanager.orbital.OrbitalManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

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

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

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

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

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

    public Spacecraft getByResourceGroup(String resourceGroupName, String spacecraftName) {
        SpacecraftInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, spacecraftName);
        if (inner != null) {
            return new SpacecraftImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

    public PagedIterable listAvailableContacts(String resourceGroupName, String spacecraftName,
        ContactParameters parameters) {
        PagedIterable inner
            = this.serviceClient().listAvailableContacts(resourceGroupName, spacecraftName, parameters);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new AvailableContactsImpl(inner1, this.manager()));
    }

    public PagedIterable listAvailableContacts(String resourceGroupName, String spacecraftName,
        ContactParameters parameters, Context context) {
        PagedIterable inner
            = this.serviceClient().listAvailableContacts(resourceGroupName, spacecraftName, parameters, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new AvailableContactsImpl(inner1, this.manager()));
    }

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

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

    private com.azure.resourcemanager.orbital.OrbitalManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy