forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#1251 from anuchandy/usage
adding usage entry point for compute and network
- Loading branch information
Showing
16 changed files
with
500 additions
and
2 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/ComputeUsage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* 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.compute; | ||
|
||
import com.microsoft.azure.management.apigeneration.Fluent; | ||
import com.microsoft.azure.management.compute.implementation.UsageInner; | ||
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; | ||
|
||
/** | ||
* An immutable client-side representation of an Azure compute resource usage info object. | ||
*/ | ||
@Fluent | ||
public interface ComputeUsage extends Wrapper<UsageInner> { | ||
/** | ||
* @return the unit of measurement. | ||
*/ | ||
ComputeUsageUnit unit(); | ||
|
||
/** | ||
* @return the current count of the allocated resources in the subscription | ||
*/ | ||
int currentValue(); | ||
|
||
/** | ||
* @return the maximum count of the resources that can be allocated in the | ||
* subscription | ||
*/ | ||
int limit(); | ||
|
||
/** | ||
* @return the name of the type of usage | ||
*/ | ||
UsageName name(); | ||
} |
69 changes: 69 additions & 0 deletions
69
...e-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/ComputeUsageUnit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* 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.compute; | ||
|
||
/** | ||
* Compute usage units. | ||
*/ | ||
public class ComputeUsageUnit { | ||
/** Static value Count for ComputeUsageUnit. */ | ||
public static final ComputeUsageUnit COUNT = new ComputeUsageUnit("Count"); | ||
|
||
/** Static value Bytes for ComputeUsageUnit. */ | ||
public static final ComputeUsageUnit BYTES = new ComputeUsageUnit("Bytes"); | ||
|
||
/** Static value Seconds for ComputeUsageUnit. */ | ||
public static final ComputeUsageUnit SECONDS = new ComputeUsageUnit("Seconds"); | ||
|
||
/** Static value Percent for ComputeUsageUnit. */ | ||
public static final ComputeUsageUnit PERCENT = new ComputeUsageUnit("Percent"); | ||
|
||
/** Static value CountsPerSecond for ComputeUsageUnit. */ | ||
public static final ComputeUsageUnit COUNTS_PER_SECOND = new ComputeUsageUnit("CountsPerSecond"); | ||
|
||
/** Static value BytesPerSecond for ComputeUsageUnit. */ | ||
public static final ComputeUsageUnit BYTES_PER_SECOND = new ComputeUsageUnit("BytesPerSecond"); | ||
|
||
/** | ||
* The string value of the compute usage unit. | ||
*/ | ||
private final String value; | ||
|
||
/** | ||
* Creates a custom value for ComputeUsageUnit. | ||
* @param value the custom value | ||
*/ | ||
public ComputeUsageUnit(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.value; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return this.value.hashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
String value = this.toString(); | ||
if (!(obj instanceof ComputeUsageUnit)) { | ||
return false; | ||
} | ||
if (obj == this) { | ||
return true; | ||
} | ||
ComputeUsageUnit rhs = (ComputeUsageUnit) obj; | ||
if (value == null) { | ||
return rhs.value == null; | ||
} else { | ||
return value.equals(rhs.value); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/ComputeUsages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* 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.compute; | ||
|
||
import com.microsoft.azure.management.apigeneration.Fluent; | ||
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListingByRegion; | ||
|
||
/** | ||
* Entry point for compute resource usage management API. | ||
*/ | ||
@Fluent | ||
public interface ComputeUsages extends SupportsListingByRegion<ComputeUsage> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...src/main/java/com/microsoft/azure/management/compute/implementation/ComputeUsageImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* 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.compute.implementation; | ||
|
||
import com.microsoft.azure.management.compute.ComputeUsage; | ||
import com.microsoft.azure.management.compute.ComputeUsageUnit; | ||
import com.microsoft.azure.management.compute.UsageName; | ||
import com.microsoft.azure.management.resources.fluentcore.model.implementation.WrapperImpl; | ||
|
||
/** | ||
* The implementation of {@link ComputeUsage}. | ||
*/ | ||
class ComputeUsageImpl extends WrapperImpl<UsageInner> implements ComputeUsage { | ||
ComputeUsageImpl(UsageInner innerObject) { | ||
super(innerObject); | ||
} | ||
|
||
@Override | ||
public ComputeUsageUnit unit() { | ||
return new ComputeUsageUnit(inner().unit()); | ||
} | ||
|
||
@Override | ||
public int currentValue() { | ||
return inner().currentValue(); | ||
} | ||
|
||
@Override | ||
public int limit() { | ||
return (int) inner().limit(); | ||
} | ||
|
||
@Override | ||
public UsageName name() { | ||
return inner().name(); | ||
} | ||
} | ||
|
42 changes: 42 additions & 0 deletions
42
...rc/main/java/com/microsoft/azure/management/compute/implementation/ComputeUsagesImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* 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.compute.implementation; | ||
|
||
import com.microsoft.azure.PagedList; | ||
import com.microsoft.azure.management.compute.ComputeUsage; | ||
import com.microsoft.azure.management.compute.ComputeUsages; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.Region; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; | ||
|
||
/** | ||
* The implementation of {@link ComputeUsages}. | ||
*/ | ||
class ComputeUsagesImpl extends ReadableWrappersImpl<ComputeUsage, ComputeUsageImpl, UsageInner> | ||
implements ComputeUsages { | ||
private final ComputeManagementClientImpl client; | ||
|
||
ComputeUsagesImpl(ComputeManagementClientImpl client) { | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
public PagedList<ComputeUsage> listByRegion(Region region) { | ||
return listByRegion(region.name()); | ||
} | ||
|
||
@Override | ||
public PagedList<ComputeUsage> listByRegion(String regionName) { | ||
return wrapList(client.usages().list(regionName)); | ||
} | ||
|
||
@Override | ||
protected ComputeUsageImpl wrapModel(UsageInner usageInner) { | ||
if (usageInner == null) { | ||
return null; | ||
} | ||
return new ComputeUsageImpl(usageInner); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ute/src/test/java/com/microsoft/azure/management/compute/ComputeUsageOperationsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.microsoft.azure.management.compute; | ||
|
||
import com.microsoft.azure.management.resources.fluentcore.arm.Region; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
public class ComputeUsageOperationsTests extends ComputeManagementTestBase { | ||
@BeforeClass | ||
public static void setup() throws Exception { | ||
createClients(); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanup() throws Exception { | ||
} | ||
|
||
@Test | ||
public void canListComputeUsages() throws Exception { | ||
List<ComputeUsage> usages = computeManager.usages().listByRegion(Region.US_EAST); | ||
Assert.assertTrue(usages.size() > 0); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkUsage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* 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.network; | ||
|
||
import com.microsoft.azure.management.apigeneration.Fluent; | ||
import com.microsoft.azure.management.network.implementation.UsageInner; | ||
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; | ||
|
||
/** | ||
* An immutable client-side representation of an Azure compute resource usage info object. | ||
*/ | ||
@Fluent | ||
public interface NetworkUsage extends Wrapper<UsageInner> { | ||
/** | ||
* @return the unit of measurement. | ||
*/ | ||
NetworkUsageUnit unit(); | ||
|
||
/** | ||
* @return the current count of the allocated resources in the subscription | ||
*/ | ||
int currentValue(); | ||
|
||
/** | ||
* @return the maximum count of the resources that can be allocated in the | ||
* subscription | ||
*/ | ||
int limit(); | ||
|
||
/** | ||
* @return the name of the type of usage | ||
*/ | ||
UsageName name(); | ||
} |
69 changes: 69 additions & 0 deletions
69
...e-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkUsageUnit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* 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.network; | ||
|
||
/** | ||
* Netowrk usage units. | ||
*/ | ||
public class NetworkUsageUnit { | ||
/** Static value Count for NetworkUsageUnit. */ | ||
public static final NetworkUsageUnit COUNT = new NetworkUsageUnit("Count"); | ||
|
||
/** Static value Bytes for NetworkUsageUnit. */ | ||
public static final NetworkUsageUnit BYTES = new NetworkUsageUnit("Bytes"); | ||
|
||
/** Static value Seconds for NetworkUsageUnit. */ | ||
public static final NetworkUsageUnit SECONDS = new NetworkUsageUnit("Seconds"); | ||
|
||
/** Static value Percent for NetworkUsageUnit. */ | ||
public static final NetworkUsageUnit PERCENT = new NetworkUsageUnit("Percent"); | ||
|
||
/** Static value CountsPerSecond for NetworkUsageUnit. */ | ||
public static final NetworkUsageUnit COUNTS_PER_SECOND = new NetworkUsageUnit("CountsPerSecond"); | ||
|
||
/** Static value BytesPerSecond for ComputeUsageUnit. */ | ||
public static final NetworkUsageUnit BYTES_PER_SECOND = new NetworkUsageUnit("BytesPerSecond"); | ||
|
||
/** | ||
* The string value of the network usage unit. | ||
*/ | ||
private final String value; | ||
|
||
/** | ||
* Creates a custom value for NetworkUsageUnit. | ||
* @param value the custom value | ||
*/ | ||
public NetworkUsageUnit(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.value; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return this.value.hashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
String value = this.toString(); | ||
if (!(obj instanceof NetworkUsageUnit)) { | ||
return false; | ||
} | ||
if (obj == this) { | ||
return true; | ||
} | ||
NetworkUsageUnit rhs = (NetworkUsageUnit) obj; | ||
if (value == null) { | ||
return rhs.value == null; | ||
} else { | ||
return value.equals(rhs.value); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkUsages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.microsoft.azure.management.network; | ||
|
||
import com.microsoft.azure.management.apigeneration.Fluent; | ||
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListingByRegion; | ||
|
||
/** | ||
* Entry point for network resource usage management API. | ||
*/ | ||
@Fluent | ||
public interface NetworkUsages extends SupportsListingByRegion<NetworkUsage> { | ||
} |
Oops, something went wrong.