Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving create(), update() into base impl classes; other corrections #803

Merged
merged 26 commits into from
Jun 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f2e5ce4
factoring create() out of concrete impls and into CreatableImpl base …
Jun 13, 2016
cd69a66
making file-based auth optional in azure tests
Jun 13, 2016
8f71680
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 13, 2016
1953efe
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 13, 2016
08f4791
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 13, 2016
ef5849d
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 13, 2016
c7a75bf
fix break due to storage changes
Jun 13, 2016
3921798
checkstyle issues
Jun 13, 2016
3ad0f32
checkstyle fixes
Jun 13, 2016
f589a61
need to suppress warnings as this is a proper use of generics in flue…
Jun 13, 2016
cf640c3
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 13, 2016
7142232
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 13, 2016
eb46495
removing unused fields to eliminate compiler warnings
Jun 13, 2016
86ea9a1
moving update() to new base class all creatable/updatable resoource i…
Jun 14, 2016
1ab2f0f
the user-facing enum KnownVirtualMachineImage should not be hidden in…
Jun 14, 2016
922cdd6
removing a no longer used class
Jun 14, 2016
31d9a60
minor javadoc fixup
Jun 14, 2016
a55dafd
model impl classes should be consistently package internal - these we…
Jun 14, 2016
e2cd17b
cleaning up leftover/missed InGroup implementation
Jun 14, 2016
2df66e1
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 14, 2016
8b85423
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 14, 2016
eaf4f39
Known*VirtualMachineImage enum is user-facing so should not be under …
Jun 14, 2016
2a0cc34
another minor checkstyle hiccup
Jun 14, 2016
f6b69ab
Merge remote-tracking branch 'upstream/master' into martin-creatable
Jun 14, 2016
a98b560
making CreatableImpl#create() return the impl, not the interface, to …
Jun 14, 2016
5c5388f
reverting *Impl#create() to return impl not interface
Jun 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.azure.management.compute.implementation;
package com.microsoft.azure.management.compute;

import com.microsoft.azure.management.compute.implementation.api.ImageReference;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.azure.management.compute.implementation;
package com.microsoft.azure.management.compute;

import com.microsoft.azure.management.compute.implementation.api.ImageReference;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.microsoft.azure.CloudException;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.compute.implementation.KnownLinuxVirtualMachineImage;
import com.microsoft.azure.management.compute.implementation.KnownWindowsVirtualMachineImage;
import com.microsoft.azure.management.compute.implementation.api.VirtualMachineInner;
import com.microsoft.azure.management.compute.implementation.api.OperatingSystemTypes;
import com.microsoft.azure.management.compute.implementation.api.CachingTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,9 @@ public AvailabilitySetImpl withFaultDomainCount(int faultDomainCount) {
return this;
}

@Override
public AvailabilitySetImpl create() throws Exception {
super.creatablesCreate();
return this;
}

@Override
public AvailabilitySetImpl update() throws Exception {
return this;
}

@Override
public AvailabilitySetImpl apply() throws Exception {
return create();
return this.create();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
class VirtualMachineImageImpl
extends IndexableWrapperImpl<VirtualMachineImageInner>
implements VirtualMachineImage {
private final VirtualMachineImagesInner client;
private final Region location;
private ImageReference imageReference;

Expand All @@ -30,7 +29,6 @@ class VirtualMachineImageImpl
this.imageReference.withOffer(offer);
this.imageReference.withSku(sku);
this.imageReference.withVersion(version);
this.client = client;
}

VirtualMachineImageImpl(Region location, String publisher, String offer, String sku, String version, VirtualMachineImageInner innerModel, VirtualMachineImagesInner client) {
Expand All @@ -41,7 +39,6 @@ class VirtualMachineImageImpl
this.imageReference.withOffer(offer);
this.imageReference.withSku(sku);
this.imageReference.withVersion(version);
this.client = client;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.microsoft.azure.management.compute.AvailabilitySet;
import com.microsoft.azure.management.compute.AvailabilitySets;
import com.microsoft.azure.management.compute.DataDisk;
import com.microsoft.azure.management.compute.KnownLinuxVirtualMachineImage;
import com.microsoft.azure.management.compute.KnownWindowsVirtualMachineImage;
import com.microsoft.azure.management.compute.PowerState;
import com.microsoft.azure.management.compute.VirtualMachine;
import com.microsoft.azure.management.compute.VirtualMachineSize;
Expand Down Expand Up @@ -154,18 +156,7 @@ public VirtualMachine refresh() throws Exception {
}

@Override
public VirtualMachine create() throws Exception {
super.creatablesCreate();
return this;
}

@Override
public VirtualMachineImpl update() throws Exception {
return this;
}

@Override
public VirtualMachine apply() throws Exception {
public VirtualMachineImpl apply() throws Exception {
return this.create();
}

Expand Down Expand Up @@ -1047,10 +1038,6 @@ private boolean dataDisksRequiresImplicitStorageAccountCreation() {
return false;
}

private boolean isStoredImage(OSDisk osDisk) {
return osDisk.image() != null;
}

private boolean isOSDiskAttached(OSDisk osDisk) {
return osDisk.createOption() == DiskCreateOptionTypes.ATTACH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
import java.util.List;

/**
<<<<<<< HEAD
* The implementation for {@link VirtualMachines}.
=======
* The type representing Azure virtual machines.
>>>>>>> eca873299bef401bbca4c7084dc790063446e986
*/
class VirtualMachinesImpl
implements VirtualMachines {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ public NetworkImpl refresh() throws Exception {
return this;
}

@Override
public NetworkImpl create() throws Exception {
super.creatablesCreate();
return this;
}

@Override
public NetworkImpl update() throws Exception {
return this;
}

@Override
public NetworkImpl apply() throws Exception {
return this.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ public NetworkInterface refresh() throws Exception {
return this;
}

@Override
public NetworkInterfaceImpl create() throws Exception {
this.creatablesCreate();
return this;
}

@Override
public NetworkInterfaceImpl update() throws Exception {
return this;
}

@Override
public NetworkInterfaceImpl apply() throws Exception {
return this.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ public NetworkSecurityGroupImpl refresh() throws Exception {
return this;
}

@Override
public NetworkSecurityGroupImpl create() throws Exception {
super.creatablesCreate();
return this;
}

@Override
public NetworkSecurityGroupImpl update() throws Exception {
return this;
}

@Override
public NetworkSecurityGroupImpl apply() throws Exception {
return this.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public PublicIpAddressImpl apply() throws Exception {
return this.create();
}

@Override
public PublicIpAddressImpl update() throws Exception {
return this;
}

@Override
public PublicIpAddress refresh() throws Exception {
ServiceResponse<PublicIPAddressInner> response =
Expand All @@ -56,12 +51,6 @@ public PublicIpAddress refresh() throws Exception {
return this;
}

@Override
public PublicIpAddressImpl create() throws Exception {
super.creatablesCreate();
return this;
}

// Setters (fluent)

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,4 @@
public interface DeploymentOperations extends
SupportsListing<DeploymentOperation>,
SupportsGettingByName<DeploymentOperation> {

/**
* Filter the deployment operations by a specific resource group.
*
* @param resourceGroup the resource group to filter by
* @return the entry point to deployment operation management API in the resource group
*/
InGroup resourceGroup(ResourceGroup resourceGroup);

/**
* Entry point to deployment operation management API in a specific resource group.
*/
interface InGroup extends
SupportsListing<DeploymentOperation>,
SupportsGettingByName<DeploymentOperation> {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public enum ResourceGroupExportTemplateOptions {
public String toString() {
return this.value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ protected AzureConfigurableImpl() {
this.restClientBuilder = AzureEnvironment.AZURE.newRestClientBuilder();
}

@SuppressWarnings("unchecked")
@Override
public T withLogLevel(HttpLoggingInterceptor.Level level) {
this.restClientBuilder = this.restClientBuilder.withLogLevel(level);
return (T) this;
}

@SuppressWarnings("unchecked")
@Override
public T withInterceptor(Interceptor interceptor) {
this.restClientBuilder = this.restClientBuilder.withInterceptor(interceptor);
return (T) this;
}

@SuppressWarnings("unchecked")
@Override
public T withUserAgent(String userAgent) {
this.restClientBuilder = this.restClientBuilder.withUserAgent(userAgent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource;

/**
* The implemenation for {@link GroupableResource}.
* The implementation for {@link GroupableResource}.
* (Internal use only)
*
* @param <FluentModelT> The fluent model type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.microsoft.azure.management.resources.fluentcore.arm.Region;
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableImpl;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl;

import java.util.Collections;
import java.util.HashMap;
Expand All @@ -29,7 +29,7 @@ public abstract class ResourceImpl<
InnerModelT extends com.microsoft.azure.Resource,
FluentModelImplT extends ResourceImpl<FluentModelT, InnerModelT, FluentModelImplT>>
extends
CreatableImpl<FluentModelT, InnerModelT>
CreatableUpdatableImpl<FluentModelT, InnerModelT, FluentModelImplT>
implements
Resource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
*
* @param <FluentModelT> the fluent model type representing the creatable resource
* @param <InnerModelT> the model inner type that the fluent model type wraps
* @param <FluentModelImplT> the fluent model implementation type
*/
public abstract class CreatableImpl<FluentModelT, InnerModelT>
public abstract class CreatableImpl<FluentModelT, InnerModelT, FluentModelImplT>
extends IndexableRefreshableWrapperImpl<FluentModelT, InnerModelT>
implements CreatableTaskGroup.RootResourceCreator {
/**
Expand All @@ -28,22 +29,6 @@ protected CreatableImpl(String name, InnerModelT innerObject) {
creatableTaskGroup = new CreatableTaskGroup(name, (Creatable<?>) this, this);
}

/**
* create this resource and creatable resources it depends on.
* <p>
* dependency resources will be created only if this is the root group otherwise
* it creates the main resource.
*
* @throws Exception the exception
*/
protected void creatablesCreate() throws Exception {
if (creatableTaskGroup.isRoot()) {
creatableTaskGroup.execute();
} else {
createResource();
}
}

/**
* add a creatable resource dependency for this resource.
*
Expand All @@ -63,6 +48,21 @@ protected Resource createdResource(String key) {
return this.creatableTaskGroup.taskResult(key);
}

/**
* Default implementation of create().
* @return the created resource
* @throws Exception when anything goes wrong
*/
@SuppressWarnings("unchecked")
public FluentModelImplT create() throws Exception {
if (creatableTaskGroup.isRoot()) {
creatableTaskGroup.execute();
} else {
createResource();
}
return (FluentModelImplT) this;
}

/**
* Creates this resource.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.management.resources.fluentcore.model.implementation;

import com.microsoft.azure.management.resources.fluentcore.model.Appliable;

/**
* The base class for all updatable resource.
*
* @param <FluentModelT> the fluent model type representing the resource
* @param <InnerModelT> the model inner type that the fluent model type wraps
* @param <FluentModelImplT> the implementation type of the fluent model
*/
public abstract class CreatableUpdatableImpl<FluentModelT, InnerModelT, FluentModelImplT>
extends CreatableImpl<FluentModelT, InnerModelT, FluentModelImplT> {

protected CreatableUpdatableImpl(String name, InnerModelT innerObject) {
super(name, innerObject);
}

/**
* Begins an update for a new resource.
* <p>
* This is the beginning of the builder pattern used to update top level resources
* in Azure. The final method completing the definition and starting the actual resource creation
* process in Azure is {@link Appliable#apply()}.
*
* @return the stage of new resource update
*/
@SuppressWarnings("unchecked")
public FluentModelImplT update() {
return (FluentModelImplT) this;
}
}
Loading