Skip to content

Commit

Permalink
Merge pull request #1008 from jianghaolu/graphkeyvault
Browse files Browse the repository at this point in the history
[Ready for review] Graph & Key Vault MGMT
  • Loading branch information
Martin Sawicki authored Sep 13, 2016
2 parents e917ebd + dd0e985 commit 8424341
Show file tree
Hide file tree
Showing 97 changed files with 6,885 additions and 2,393 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable;
import com.microsoft.azure.management.resources.fluentcore.model.Updatable;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;

import java.util.List;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AvailabilitySetsImpl
}

@Override
public PagedList<AvailabilitySet> list() throws CloudException, IOException {
public PagedList<AvailabilitySet> list() throws RestException, IOException {
return new GroupPagedList<AvailabilitySet>(this.myManager.resourceManager().resourceGroups().list()) {
@Override
public List<AvailabilitySet> listNextGroup(String resourceGroupName) throws RestException, IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* @param <ChildT> the type of child paged list item
*/
final class ChildListFlattener<ParentT, ChildT> {
protected final String switchToCousin = "switchToCousin";
protected Iterator<ParentT> parentItr;
protected PagedList<ChildT> currentChildList;
protected PagedList<ChildT> cousinList;
private final String switchToCousin = "switchToCousin";
private Iterator<ParentT> parentItr;
private PagedList<ChildT> currentChildList;
private final ChildListLoader<ParentT, ChildT> childListLoader;

/**
Expand Down Expand Up @@ -67,52 +66,22 @@ public PagedList<ChildT> flatten() throws CloudException, IOException {
if (this.currentChildList == null) {
return emptyPagedList();
}
// setCousin sets the next child paged list (i.e. the current child list's immediate cousin).
// we need to know in advance whether there is going to be a next child paged list (cousin).
// This is because the 'next link' of the current child paged list's last page will be null.
// when the PagedList sees next link as null it assumes there is no more pages hence it won't
// call nextPage and iteration stops, if cousin presents then 'childListPage' method replace
// this null with a marker indicating there is more pages.
setCousin();
return new PagedList<ChildT>(childListPage(currentChildList.currentPage())) {
@Override
public Page<ChildT> nextPage(String nextPageLink) throws RestException, IOException {
if (nextPageLink.equalsIgnoreCase(switchToCousin)) {
// Reached end of current child paged list, make next child list(cousin) as current
// paged list and return it's first page.
currentChildList = cousinList;
setCousin();
currentChildList = nextChildList();
return childListPage(currentChildList.currentPage());
} else {
currentChildList.loadNextPage();
if (currentChildList.currentPage().getNextPageLink() == null) {
// This is the last page of the current child paged list set it's cousin
// so that next call to nextPage can start using it.
setCousin();
}
return childListPage(currentChildList.currentPage());
}
}
};
}

/**
* @return true if the current child paged list has a cousin
*/
private boolean hasCousin() {
return this.cousinList != null;
}

/**
* Locate and sets the cousin list (the next child paged list).
*
* @throws CloudException exceptions thrown from the cloud
* @throws IOException exceptions thrown from serialization/deserialization
*/
private void setCousin() throws CloudException, IOException {
cousinList = nextChildList();
}

/**
* Returns the next child paged list containing at least one item.
* <p>
Expand Down Expand Up @@ -152,7 +121,7 @@ public String getNextPageLink() {
return page.getNextPageLink();
}

if (hasCousin()) {
if (parentItr.hasNext()) {
// The current child paged list has no more pages so switch to it's cousin list
return switchToCousin;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import com.microsoft.azure.CloudException;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.compute.VirtualMachineImage;
import com.microsoft.azure.management.compute.VirtualMachineImages;
import com.microsoft.azure.management.compute.VirtualMachineOffer;
import com.microsoft.azure.management.compute.VirtualMachinePublisher;
import com.microsoft.azure.management.compute.VirtualMachinePublishers;
import com.microsoft.azure.management.compute.VirtualMachineImage;
import com.microsoft.azure.management.compute.VirtualMachineImages;
import com.microsoft.azure.management.compute.VirtualMachineSku;
import com.microsoft.azure.management.resources.fluentcore.arm.Region;

import java.io.IOException;

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

import com.microsoft.azure.CloudException;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.compute.VirtualMachineImage;
Expand All @@ -25,7 +24,7 @@ class VirtualMachineImagesInSkuImpl implements VirtualMachineImagesInSku {
this.innerCollection = innerCollection;
}

public PagedList<VirtualMachineImage> list() throws CloudException, IOException {
public PagedList<VirtualMachineImage> list() throws RestException, IOException {
final List<VirtualMachineImage> images = new ArrayList<>();
for (VirtualMachineImageResourceInner inner
: innerCollection.list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/
package com.microsoft.azure.management.compute.implementation;

import com.microsoft.azure.CloudException;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.compute.VirtualMachineOffer;
import com.microsoft.azure.management.compute.VirtualMachineSkus;
import com.microsoft.azure.management.compute.VirtualMachineSku;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl;
import com.microsoft.rest.RestException;

import java.io.IOException;

Expand All @@ -30,7 +30,7 @@ class VirtualMachineSkusImpl
}

@Override
public PagedList<VirtualMachineSku> list() throws CloudException, IOException {
public PagedList<VirtualMachineSku> list() throws RestException, IOException {
return wrapList(innerCollection.listSkus(
offer.region().toString(),
offer.publisher().name(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static void createClients() {
authEnv = new AzureEnvironment(
"https://login.windows-ppe.net/",
"https://management.core.windows.net/",
true,
"https://api-dogfood.resources.windows-int.net");
"https://api-dogfood.resources.windows-int.net",
"https://graph.windows.net");
break;
case "test":
armUri = "https://api-dogfood.resources.windows-int.net";
Expand All @@ -59,8 +59,8 @@ public static void createClients() {
authEnv = new AzureEnvironment(
"https://login.windows-ppe.net/",
"https://management.core.windows.net/",
true,
"https://api-dogfood.resources.windows-int.net");
"https://api-dogfood.resources.windows-int.net",
"https://graph.windows.net");
break;
default: // default to production
armUri = "https://management.azure.com";
Expand All @@ -74,7 +74,6 @@ public static void createClients() {
System.getenv("arm.domain"),
System.getenv("arm.username"),
System.getenv("arm.password"),
null,
authEnv);

RestClient restClient = new RestClient.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public static void createClients() {
System.getenv("arm.domain"),
System.getenv("arm.username"),
System.getenv("arm.password"),
null,
AzureEnvironment.AZURE);

RestClient restClient = new RestClient.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static void createClients() {
System.getenv("arm.domain"),
System.getenv("arm.username"),
System.getenv("arm.password"),
null,
AzureEnvironment.AZURE);

RestClient restClient = new RestClient.Builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* 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.graphrbac;

import com.microsoft.azure.management.graphrbac.implementation.ADGroupInner;
import com.microsoft.azure.management.resources.fluentcore.model.Creatable;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;

/**
* An immutable client-side representation of an Azure AD group.
*/
public interface ActiveDirectoryGroup extends
Wrapper<ADGroupInner> {
/**
* @return object Id.
*/
String objectId();

/**
* @return object type.
*/
String objectType();

/**
* @return group display name.
*/
String displayName();

/**
* @return security enabled field.
*/
Boolean securityEnabled();

/**
* @return mail field.
*/
String mail();

/**************************************************************
* Fluent interfaces to provision a Group
**************************************************************/

/**
* Container interface for all the definitions that need to be implemented.
*/
interface Definition extends
DefinitionStages.Blank,
DefinitionStages.WithDisplayName,
DefinitionStages.WithMailNickname,
DefinitionStages.WithCreate {
}

/**
* Grouping of all the group definition stages.
*/
interface DefinitionStages {
/**
* The first stage of the group definition.
*/
interface Blank extends WithDisplayName {
}

/**
* The stage of group definition allowing display name to be specified.
*/
interface WithDisplayName {
/**
* Specifies the display name of the group.
*
* @param displayName the human readable display name
* @return the next stage of group definition
*/
WithMailNickname withDisplayName(String displayName);
}

/**
* The stage of group definition allowing mail nickname to be specified.
*/
interface WithMailNickname {
/**
* Specifies the mail nickname of the group.
*
* @param mailNickname the mail nickname for the group
* @return the next stage of group definition
*/
WithCreate withMailNickname(String mailNickname);
}

/**
* An AD group definition with sufficient inputs to create a new
* group in the cloud, but exposing additional optional inputs to
* specify.
*/
interface WithCreate extends
Creatable<ActiveDirectoryGroup> {
}
}

/**
* Grouping of all the group update stages.
*/
interface UpdateStages {
}

/**
* The template for a group update operation, containing all the settings that can be modified.
*/
interface Update {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.management.graphrbac;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.microsoft.rest.serializer.JsonFlatten;

/**
* Active Directory error information.
*/
@JsonFlatten
public class GraphError {
/**
* Error code.
*/
@JsonProperty(value = "odata\\.error.code")
private String code;

/**
* Error message value.
*/
@JsonProperty(value = "odata\\.error.message.value")
private String message;

/**
* Get the code value.
*
* @return the code value
*/
public String code() {
return this.code;
}

/**
* Set the code value.
*
* @param code the code value to set
* @return the GraphError object itself.
*/
public GraphError withCode(String code) {
this.code = code;
return this;
}

/**
* Get the message value.
*
* @return the message value
*/
public String message() {
return this.message;
}

/**
* Set the message value.
*
* @param message the message value to set
* @return the GraphError object itself.
*/
public GraphError withMessage(String message) {
this.message = message;
return this;
}

}
Loading

0 comments on commit 8424341

Please sign in to comment.