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

com.azure.resourcemanager.compute.implementation.GalleryImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Compute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt

There is a newer version: 2.44.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.resourcemanager.compute.implementation;

import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.resourcemanager.compute.ComputeManager;
import com.azure.resourcemanager.compute.models.Gallery;
import com.azure.resourcemanager.compute.models.GalleryImage;
import com.azure.resourcemanager.compute.fluent.models.GalleryInner;
import com.azure.resourcemanager.compute.models.GalleryUpdate;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import reactor.core.publisher.Mono;

/** The implementation for Gallery and its create and update interfaces. */
class GalleryImpl extends GroupableResourceImpl
    implements Gallery, Gallery.Definition, Gallery.Update {

    private GalleryUpdate updateParameters = new GalleryUpdate();

    GalleryImpl(String name, GalleryInner inner, ComputeManager manager) {
        super(name, inner, manager);
    }

    @Override
    public Mono createResourceAsync() {
        return manager()
            .serviceClient()
            .getGalleries()
            .createOrUpdateAsync(this.resourceGroupName(), this.name(), this.innerModel())
            .map(innerToFluentMap(this));
    }

    @Override
    public Mono updateResourceAsync() {
        if (this.innerModel().tags() != null) {
            // tags is set by super
            updateParameters.withTags(this.innerModel().tags());
        }

        return manager()
            .serviceClient()
            .getGalleries()
            .updateAsync(this.resourceGroupName(), this.name(), updateParameters)
            .map(innerToFluentMap(this));
    }

    @Override
    public GalleryImpl update() {
        updateParameters = new GalleryUpdate();
        return super.update();
    }

    @Override
    protected Mono getInnerAsync() {
        return manager().serviceClient().getGalleries().getByResourceGroupAsync(this.resourceGroupName(), this.name());
    }

    @Override
    public boolean isInCreateMode() {
        return this.innerModel().id() == null;
    }

    @Override
    public String description() {
        return this.innerModel().description();
    }

    @Override
    public String uniqueName() {
        return this.innerModel().identifier().uniqueName();
    }

    @Override
    public String provisioningState() {
        return this.innerModel().provisioningState().toString();
    }

    @Override
    public Mono getImageAsync(String imageName) {
        return this.manager().galleryImages().getByGalleryAsync(this.resourceGroupName(), this.name(), imageName);
    }

    @Override
    public GalleryImage getImage(String imageName) {
        return this.manager().galleryImages().getByGallery(this.resourceGroupName(), this.name(), imageName);
    }

    @Override
    public PagedFlux listImagesAsync() {
        return this.manager().galleryImages().listByGalleryAsync(this.resourceGroupName(), this.name());
    }

    @Override
    public PagedIterable listImages() {
        return this.manager().galleryImages().listByGallery(this.resourceGroupName(), this.name());
    }

    @Override
    public GalleryImpl withDescription(String description) {
        if (isInCreateMode()) {
            this.innerModel().withDescription(description);
        } else {
            updateParameters.withDescription(description);
        }
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy