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

[Ready for review] Graph & Key Vault MGMT #1008

Merged
merged 33 commits into from
Sep 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0484ce6
Generate graph and keyvault clients
jianghaolu Sep 13, 2016
36616ae
Add interfaces for vault & access policy
jianghaolu Jul 27, 2016
b112eff
Basic Create
jianghaolu Jul 27, 2016
1fe0f3f
Add graph to key vault flow
jianghaolu Aug 1, 2016
34207df
Add update flow to vault
jianghaolu Aug 3, 2016
3a3b5d5
Add authorize flow
jianghaolu Aug 3, 2016
262a7ee
Rename getters for Users & ServicePrincipals
jianghaolu Aug 3, 2016
fd4ce07
Add group & add graph endpoints to AzureEnvironment
jianghaolu Aug 4, 2016
1d9c0c3
Address some review feedback
jianghaolu Aug 4, 2016
622029c
Basic impl for vault
jianghaolu Aug 4, 2016
e9aca42
default tenant id
jianghaolu Aug 8, 2016
4b86b42
Regen graph and a bunch of refactors
jianghaolu Aug 8, 2016
52449ff
Allow specifying upn and spn
jianghaolu Aug 10, 2016
ef9f961
more checks
jianghaolu Aug 10, 2016
1e307c4
Move key vault tests to correct location
jianghaolu Aug 17, 2016
cd66a20
Regenerate graph & keyvault client
jianghaolu Aug 30, 2016
ad615f2
basic get in Graph in observable
jianghaolu Aug 31, 2016
08fac8d
Supports spn & upn config in vault creation
jianghaolu Sep 2, 2016
e0106a5
Enable user login
jianghaolu Sep 3, 2016
eca2ca5
Add asserts to keyvault tests
jianghaolu Sep 7, 2016
000da13
Regenerate keyvault & graph with latest autorest
jianghaolu Sep 7, 2016
665884d
Fix merge errors and key vault test
jianghaolu Sep 7, 2016
25ae568
Add tenantId requirement on roll-up client
jianghaolu Sep 7, 2016
a6ea6bb
Add key vault sample
jianghaolu Sep 8, 2016
f03d29f
more fixes in key vault
jianghaolu Sep 8, 2016
ce5012a
Add key vault to roll-up client
jianghaolu Sep 8, 2016
2d12e85
Allow empty pages in paged list
jianghaolu Sep 8, 2016
907d8c0
Adapt group paged list to new paged list
jianghaolu Sep 9, 2016
7e66016
Child list flattener doesn't need to worry about cousins
jianghaolu Sep 9, 2016
53ad799
Add javadocs and address checkstyle
jianghaolu Sep 10, 2016
93be0f4
Fix merge errors
jianghaolu Sep 13, 2016
dd31927
Address cr feedback in key vault
jianghaolu Sep 13, 2016
dd0e985
Rename Group to ActiveDirectoryGroup
jianghaolu Sep 13, 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
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