From c6f0bccb9054ded60701c220d6d463145e9f798f Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 12 Oct 2018 00:47:06 +0000 Subject: [PATCH] Generated from b2f02dca5d73046118161dec67291827b68642b2 Add graphrbac/data-plane/readme.typescript.md --- Gopkg.lock | 9 + profiles/latest/graphrbac/graphrbac/models.go | 24 +- .../preview/graphrbac/graphrbac/models.go | 24 +- .../graphrbac/1.6/graphrbac/applications.go | 104 +- .../1.6/graphrbac/deletedapplications.go | 314 ++++++ services/graphrbac/1.6/graphrbac/groups.go | 251 ++++- services/graphrbac/1.6/graphrbac/models.go | 987 ++++++++++-------- services/graphrbac/1.6/graphrbac/oauth2.go | 28 +- services/graphrbac/1.6/graphrbac/objects.go | 90 +- .../1.6/graphrbac/serviceprincipals.go | 104 +- .../graphrbac/1.6/graphrbac/signedinuser.go | 242 +++++ 11 files changed, 1637 insertions(+), 540 deletions(-) create mode 100644 services/graphrbac/1.6/graphrbac/deletedapplications.go create mode 100644 services/graphrbac/1.6/graphrbac/signedinuser.go diff --git a/Gopkg.lock b/Gopkg.lock index 760666466753..b25dcd18580c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -176,6 +176,14 @@ revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194" version = "v1.2.0" +[[projects]] + digest = "1:7365acd48986e205ccb8652cc746f09c8b7876030d53710ea6ef7d0bd0dcd7ca" + name = "github.com/pkg/errors" + packages = ["."] + pruneopts = "" + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" + [[projects]] digest = "1:7f569d906bdd20d906b606415b7d794f798f91a62fcfb6a4daa6d50690fb7a3f" name = "github.com/satori/go.uuid" @@ -324,6 +332,7 @@ "github.com/marstr/guid", "github.com/marstr/randname", "github.com/mitchellh/go-homedir", + "github.com/pkg/errors", "github.com/satori/go.uuid", "github.com/shopspring/decimal", "github.com/spf13/cobra", diff --git a/profiles/latest/graphrbac/graphrbac/models.go b/profiles/latest/graphrbac/graphrbac/models.go index 387fdbf7d796..d09352bdf9e5 100644 --- a/profiles/latest/graphrbac/graphrbac/models.go +++ b/profiles/latest/graphrbac/graphrbac/models.go @@ -28,6 +28,7 @@ const ( ) type BaseClient = original.BaseClient +type DeletedApplicationsClient = original.DeletedApplicationsClient type DomainsClient = original.DomainsClient type GroupsClient = original.GroupsClient type ObjectType = original.ObjectType @@ -47,27 +48,26 @@ const ( Member UserType = original.Member ) -type AADObject = original.AADObject +type AddOwnerParameters = original.AddOwnerParameters type ADGroup = original.ADGroup type Application = original.Application -type ApplicationAddOwnerParameters = original.ApplicationAddOwnerParameters type ApplicationCreateParameters = original.ApplicationCreateParameters type ApplicationListResult = original.ApplicationListResult type ApplicationListResultIterator = original.ApplicationListResultIterator type ApplicationListResultPage = original.ApplicationListResultPage type ApplicationUpdateParameters = original.ApplicationUpdateParameters +type AppRole = original.AppRole type CheckGroupMembershipParameters = original.CheckGroupMembershipParameters type CheckGroupMembershipResult = original.CheckGroupMembershipResult type BasicDirectoryObject = original.BasicDirectoryObject type DirectoryObject = original.DirectoryObject type DirectoryObjectListResult = original.DirectoryObjectListResult +type DirectoryObjectListResultIterator = original.DirectoryObjectListResultIterator +type DirectoryObjectListResultPage = original.DirectoryObjectListResultPage type Domain = original.Domain type DomainListResult = original.DomainListResult type ErrorMessage = original.ErrorMessage type GetObjectsParameters = original.GetObjectsParameters -type GetObjectsResult = original.GetObjectsResult -type GetObjectsResultIterator = original.GetObjectsResultIterator -type GetObjectsResultPage = original.GetObjectsResultPage type GraphError = original.GraphError type GroupAddMemberParameters = original.GroupAddMemberParameters type GroupCreateParameters = original.GroupCreateParameters @@ -92,6 +92,7 @@ type ServicePrincipalCreateParameters = original.ServicePrincipalCreateParameter type ServicePrincipalListResult = original.ServicePrincipalListResult type ServicePrincipalListResultIterator = original.ServicePrincipalListResultIterator type ServicePrincipalListResultPage = original.ServicePrincipalListResultPage +type ServicePrincipalUpdateParameters = original.ServicePrincipalUpdateParameters type SignInName = original.SignInName type User = original.User type UserBase = original.UserBase @@ -105,6 +106,7 @@ type UserUpdateParameters = original.UserUpdateParameters type OAuth2Client = original.OAuth2Client type ObjectsClient = original.ObjectsClient type ServicePrincipalsClient = original.ServicePrincipalsClient +type SignedInUserClient = original.SignedInUserClient type UsersClient = original.UsersClient func NewApplicationsClient(tenantID string) ApplicationsClient { @@ -119,6 +121,12 @@ func New(tenantID string) BaseClient { func NewWithBaseURI(baseURI string, tenantID string) BaseClient { return original.NewWithBaseURI(baseURI, tenantID) } +func NewDeletedApplicationsClient(tenantID string) DeletedApplicationsClient { + return original.NewDeletedApplicationsClient(tenantID) +} +func NewDeletedApplicationsClientWithBaseURI(baseURI string, tenantID string) DeletedApplicationsClient { + return original.NewDeletedApplicationsClientWithBaseURI(baseURI, tenantID) +} func NewDomainsClient(tenantID string) DomainsClient { return original.NewDomainsClient(tenantID) } @@ -155,6 +163,12 @@ func NewServicePrincipalsClient(tenantID string) ServicePrincipalsClient { func NewServicePrincipalsClientWithBaseURI(baseURI string, tenantID string) ServicePrincipalsClient { return original.NewServicePrincipalsClientWithBaseURI(baseURI, tenantID) } +func NewSignedInUserClient(tenantID string) SignedInUserClient { + return original.NewSignedInUserClient(tenantID) +} +func NewSignedInUserClientWithBaseURI(baseURI string, tenantID string) SignedInUserClient { + return original.NewSignedInUserClientWithBaseURI(baseURI, tenantID) +} func NewUsersClient(tenantID string) UsersClient { return original.NewUsersClient(tenantID) } diff --git a/profiles/preview/graphrbac/graphrbac/models.go b/profiles/preview/graphrbac/graphrbac/models.go index b37affb99dec..7cf5dfb6b86c 100644 --- a/profiles/preview/graphrbac/graphrbac/models.go +++ b/profiles/preview/graphrbac/graphrbac/models.go @@ -28,6 +28,7 @@ const ( ) type BaseClient = original.BaseClient +type DeletedApplicationsClient = original.DeletedApplicationsClient type DomainsClient = original.DomainsClient type GroupsClient = original.GroupsClient type ObjectType = original.ObjectType @@ -47,27 +48,26 @@ const ( Member UserType = original.Member ) -type AADObject = original.AADObject +type AddOwnerParameters = original.AddOwnerParameters type ADGroup = original.ADGroup type Application = original.Application -type ApplicationAddOwnerParameters = original.ApplicationAddOwnerParameters type ApplicationCreateParameters = original.ApplicationCreateParameters type ApplicationListResult = original.ApplicationListResult type ApplicationListResultIterator = original.ApplicationListResultIterator type ApplicationListResultPage = original.ApplicationListResultPage type ApplicationUpdateParameters = original.ApplicationUpdateParameters +type AppRole = original.AppRole type CheckGroupMembershipParameters = original.CheckGroupMembershipParameters type CheckGroupMembershipResult = original.CheckGroupMembershipResult type BasicDirectoryObject = original.BasicDirectoryObject type DirectoryObject = original.DirectoryObject type DirectoryObjectListResult = original.DirectoryObjectListResult +type DirectoryObjectListResultIterator = original.DirectoryObjectListResultIterator +type DirectoryObjectListResultPage = original.DirectoryObjectListResultPage type Domain = original.Domain type DomainListResult = original.DomainListResult type ErrorMessage = original.ErrorMessage type GetObjectsParameters = original.GetObjectsParameters -type GetObjectsResult = original.GetObjectsResult -type GetObjectsResultIterator = original.GetObjectsResultIterator -type GetObjectsResultPage = original.GetObjectsResultPage type GraphError = original.GraphError type GroupAddMemberParameters = original.GroupAddMemberParameters type GroupCreateParameters = original.GroupCreateParameters @@ -92,6 +92,7 @@ type ServicePrincipalCreateParameters = original.ServicePrincipalCreateParameter type ServicePrincipalListResult = original.ServicePrincipalListResult type ServicePrincipalListResultIterator = original.ServicePrincipalListResultIterator type ServicePrincipalListResultPage = original.ServicePrincipalListResultPage +type ServicePrincipalUpdateParameters = original.ServicePrincipalUpdateParameters type SignInName = original.SignInName type User = original.User type UserBase = original.UserBase @@ -105,6 +106,7 @@ type UserUpdateParameters = original.UserUpdateParameters type OAuth2Client = original.OAuth2Client type ObjectsClient = original.ObjectsClient type ServicePrincipalsClient = original.ServicePrincipalsClient +type SignedInUserClient = original.SignedInUserClient type UsersClient = original.UsersClient func NewApplicationsClient(tenantID string) ApplicationsClient { @@ -119,6 +121,12 @@ func New(tenantID string) BaseClient { func NewWithBaseURI(baseURI string, tenantID string) BaseClient { return original.NewWithBaseURI(baseURI, tenantID) } +func NewDeletedApplicationsClient(tenantID string) DeletedApplicationsClient { + return original.NewDeletedApplicationsClient(tenantID) +} +func NewDeletedApplicationsClientWithBaseURI(baseURI string, tenantID string) DeletedApplicationsClient { + return original.NewDeletedApplicationsClientWithBaseURI(baseURI, tenantID) +} func NewDomainsClient(tenantID string) DomainsClient { return original.NewDomainsClient(tenantID) } @@ -155,6 +163,12 @@ func NewServicePrincipalsClient(tenantID string) ServicePrincipalsClient { func NewServicePrincipalsClientWithBaseURI(baseURI string, tenantID string) ServicePrincipalsClient { return original.NewServicePrincipalsClientWithBaseURI(baseURI, tenantID) } +func NewSignedInUserClient(tenantID string) SignedInUserClient { + return original.NewSignedInUserClient(tenantID) +} +func NewSignedInUserClientWithBaseURI(baseURI string, tenantID string) SignedInUserClient { + return original.NewSignedInUserClientWithBaseURI(baseURI, tenantID) +} func NewUsersClient(tenantID string) UsersClient { return original.NewUsersClient(tenantID) } diff --git a/services/graphrbac/1.6/graphrbac/applications.go b/services/graphrbac/1.6/graphrbac/applications.go index 61c0c5313ee9..9e96795dfde0 100644 --- a/services/graphrbac/1.6/graphrbac/applications.go +++ b/services/graphrbac/1.6/graphrbac/applications.go @@ -46,7 +46,7 @@ func NewApplicationsClientWithBaseURI(baseURI string, tenantID string) Applicati // applicationObjectID - the object ID of the application to which to add the owner. // parameters - the URL of the owner object, such as // https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. -func (client ApplicationsClient) AddOwner(ctx context.Context, applicationObjectID string, parameters ApplicationAddOwnerParameters) (result autorest.Response, err error) { +func (client ApplicationsClient) AddOwner(ctx context.Context, applicationObjectID string, parameters AddOwnerParameters) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { @@ -75,7 +75,7 @@ func (client ApplicationsClient) AddOwner(ctx context.Context, applicationObject } // AddOwnerPreparer prepares the AddOwner request. -func (client ApplicationsClient) AddOwnerPreparer(ctx context.Context, applicationObjectID string, parameters ApplicationAddOwnerParameters) (*http.Request, error) { +func (client ApplicationsClient) AddOwnerPreparer(ctx context.Context, applicationObjectID string, parameters AddOwnerParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ "applicationObjectId": autorest.Encode("path", applicationObjectID), "tenantID": autorest.Encode("path", client.TenantID), @@ -530,7 +530,8 @@ func (client ApplicationsClient) ListNextResponder(resp *http.Response) (result // ListOwners the owners are a set of non-admin users who are allowed to modify this object. // Parameters: // applicationObjectID - the object ID of the application for which to get owners. -func (client ApplicationsClient) ListOwners(ctx context.Context, applicationObjectID string) (result DirectoryObjectListResult, err error) { +func (client ApplicationsClient) ListOwners(ctx context.Context, applicationObjectID string) (result DirectoryObjectListResultPage, err error) { + result.fn = client.listOwnersNextResults req, err := client.ListOwnersPreparer(ctx, applicationObjectID) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListOwners", nil, "Failure preparing request") @@ -539,12 +540,12 @@ func (client ApplicationsClient) ListOwners(ctx context.Context, applicationObje resp, err := client.ListOwnersSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.dolr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListOwners", resp, "Failure sending request") return } - result, err = client.ListOwnersResponder(resp) + result.dolr, err = client.ListOwnersResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListOwners", resp, "Failure responding to request") } @@ -592,6 +593,33 @@ func (client ApplicationsClient) ListOwnersResponder(resp *http.Response) (resul return } +// listOwnersNextResults retrieves the next set of results, if any. +func (client ApplicationsClient) listOwnersNextResults(lastResults DirectoryObjectListResult) (result DirectoryObjectListResult, err error) { + req, err := lastResults.directoryObjectListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "listOwnersNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListOwnersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "listOwnersNextResults", resp, "Failure sending next results request") + } + result, err = client.ListOwnersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "listOwnersNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListOwnersComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationsClient) ListOwnersComplete(ctx context.Context, applicationObjectID string) (result DirectoryObjectListResultIterator, err error) { + result.page, err = client.ListOwners(ctx, applicationObjectID) + return +} + // ListPasswordCredentials get the passwordCredentials associated with an application. // Parameters: // applicationObjectID - application object ID. @@ -724,6 +752,72 @@ func (client ApplicationsClient) PatchResponder(resp *http.Response) (result aut return } +// RemoveOwner remove a member from owners. +// Parameters: +// applicationObjectID - the object ID of the application from which to remove the owner. +// ownerObjectID - owner object id +func (client ApplicationsClient) RemoveOwner(ctx context.Context, applicationObjectID string, ownerObjectID string) (result autorest.Response, err error) { + req, err := client.RemoveOwnerPreparer(ctx, applicationObjectID, ownerObjectID) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "RemoveOwner", nil, "Failure preparing request") + return + } + + resp, err := client.RemoveOwnerSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "RemoveOwner", resp, "Failure sending request") + return + } + + result, err = client.RemoveOwnerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "RemoveOwner", resp, "Failure responding to request") + } + + return +} + +// RemoveOwnerPreparer prepares the RemoveOwner request. +func (client ApplicationsClient) RemoveOwnerPreparer(ctx context.Context, applicationObjectID string, ownerObjectID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationObjectId": autorest.Encode("path", applicationObjectID), + "ownerObjectId": autorest.Encode("path", ownerObjectID), + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/applications/{applicationObjectId}/$links/owners/{ownerObjectId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RemoveOwnerSender sends the RemoveOwner request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) RemoveOwnerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// RemoveOwnerResponder handles the response to the RemoveOwner request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) RemoveOwnerResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // UpdateKeyCredentials update the keyCredentials associated with an application. // Parameters: // applicationObjectID - application object ID. diff --git a/services/graphrbac/1.6/graphrbac/deletedapplications.go b/services/graphrbac/1.6/graphrbac/deletedapplications.go new file mode 100644 index 000000000000..3aa44bb0cdcd --- /dev/null +++ b/services/graphrbac/1.6/graphrbac/deletedapplications.go @@ -0,0 +1,314 @@ +package graphrbac + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// DeletedApplicationsClient is the the Graph RBAC Management Client +type DeletedApplicationsClient struct { + BaseClient +} + +// NewDeletedApplicationsClient creates an instance of the DeletedApplicationsClient client. +func NewDeletedApplicationsClient(tenantID string) DeletedApplicationsClient { + return NewDeletedApplicationsClientWithBaseURI(DefaultBaseURI, tenantID) +} + +// NewDeletedApplicationsClientWithBaseURI creates an instance of the DeletedApplicationsClient client. +func NewDeletedApplicationsClientWithBaseURI(baseURI string, tenantID string) DeletedApplicationsClient { + return DeletedApplicationsClient{NewWithBaseURI(baseURI, tenantID)} +} + +// HardDelete hard-delete an application. +// Parameters: +// applicationObjectID - application object ID. +func (client DeletedApplicationsClient) HardDelete(ctx context.Context, applicationObjectID string) (result autorest.Response, err error) { + req, err := client.HardDeletePreparer(ctx, applicationObjectID) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "HardDelete", nil, "Failure preparing request") + return + } + + resp, err := client.HardDeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "HardDelete", resp, "Failure sending request") + return + } + + result, err = client.HardDeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "HardDelete", resp, "Failure responding to request") + } + + return +} + +// HardDeletePreparer prepares the HardDelete request. +func (client DeletedApplicationsClient) HardDeletePreparer(ctx context.Context, applicationObjectID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationObjectId": autorest.Encode("path", applicationObjectID), + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/deletedApplications/{applicationObjectId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// HardDeleteSender sends the HardDelete request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedApplicationsClient) HardDeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// HardDeleteResponder handles the response to the HardDelete request. The method always +// closes the http.Response Body. +func (client DeletedApplicationsClient) HardDeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// List gets a list of deleted applications in the directory. +// Parameters: +// filter - the filter to apply to the operation. +func (client DeletedApplicationsClient) List(ctx context.Context, filter string) (result ApplicationListResultPage, err error) { + result.fn = func(lastResult ApplicationListResult) (ApplicationListResult, error) { + if lastResult.OdataNextLink == nil || len(to.String(lastResult.OdataNextLink)) < 1 { + return ApplicationListResult{}, nil + } + return client.ListNext(ctx, *lastResult.OdataNextLink) + } + req, err := client.ListPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "List", resp, "Failure sending request") + return + } + + result.alr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client DeletedApplicationsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/deletedApplications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedApplicationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DeletedApplicationsClient) ListResponder(resp *http.Response) (result ApplicationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client DeletedApplicationsClient) ListComplete(ctx context.Context, filter string) (result ApplicationListResultIterator, err error) { + result.page, err = client.List(ctx, filter) + return +} + +// ListNext gets a list of deleted applications in the directory. +// Parameters: +// nextLink - next link for the list operation. +func (client DeletedApplicationsClient) ListNext(ctx context.Context, nextLink string) (result ApplicationListResult, err error) { + req, err := client.ListNextPreparer(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "ListNext", nil, "Failure preparing request") + return + } + + resp, err := client.ListNextSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "ListNext", resp, "Failure sending request") + return + } + + result, err = client.ListNextResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "ListNext", resp, "Failure responding to request") + } + + return +} + +// ListNextPreparer prepares the ListNext request. +func (client DeletedApplicationsClient) ListNextPreparer(ctx context.Context, nextLink string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "nextLink": nextLink, + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/{nextLink}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListNextSender sends the ListNext request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedApplicationsClient) ListNextSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListNextResponder handles the response to the ListNext request. The method always +// closes the http.Response Body. +func (client DeletedApplicationsClient) ListNextResponder(resp *http.Response) (result ApplicationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Restore restores the deleted application in the directory. +// Parameters: +// objectID - application object ID. +func (client DeletedApplicationsClient) Restore(ctx context.Context, objectID string) (result Application, err error) { + req, err := client.RestorePreparer(ctx, objectID) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "Restore", nil, "Failure preparing request") + return + } + + resp, err := client.RestoreSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "Restore", resp, "Failure sending request") + return + } + + result, err = client.RestoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "Restore", resp, "Failure responding to request") + } + + return +} + +// RestorePreparer prepares the Restore request. +func (client DeletedApplicationsClient) RestorePreparer(ctx context.Context, objectID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "objectId": autorest.Encode("path", objectID), + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/deletedApplications/{objectId}/restore", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RestoreSender sends the Restore request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedApplicationsClient) RestoreSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// RestoreResponder handles the response to the Restore request. The method always +// closes the http.Response Body. +func (client DeletedApplicationsClient) RestoreResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/graphrbac/1.6/graphrbac/groups.go b/services/graphrbac/1.6/graphrbac/groups.go index 9fbe85cbbd30..00358ad27722 100644 --- a/services/graphrbac/1.6/graphrbac/groups.go +++ b/services/graphrbac/1.6/graphrbac/groups.go @@ -115,6 +115,80 @@ func (client GroupsClient) AddMemberResponder(resp *http.Response) (result autor return } +// AddOwner add an owner to a group. +// Parameters: +// objectID - the object ID of the application to which to add the owner. +// parameters - the URL of the owner object, such as +// https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd. +func (client GroupsClient) AddOwner(ctx context.Context, objectID string, parameters AddOwnerParameters) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("graphrbac.GroupsClient", "AddOwner", err.Error()) + } + + req, err := client.AddOwnerPreparer(ctx, objectID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "AddOwner", nil, "Failure preparing request") + return + } + + resp, err := client.AddOwnerSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "AddOwner", resp, "Failure sending request") + return + } + + result, err = client.AddOwnerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "AddOwner", resp, "Failure responding to request") + } + + return +} + +// AddOwnerPreparer prepares the AddOwner request. +func (client GroupsClient) AddOwnerPreparer(ctx context.Context, objectID string, parameters AddOwnerParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "objectId": autorest.Encode("path", objectID), + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/groups/{objectId}/$links/owners", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddOwnerSender sends the AddOwner request. The method will close the +// http.Response Body if it receives an error. +func (client GroupsClient) AddOwnerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddOwnerResponder handles the response to the AddOwner request. The method always +// closes the http.Response Body. +func (client GroupsClient) AddOwnerResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // Create create a group in the directory. // Parameters: // parameters - the parameters for the group to create. @@ -322,10 +396,10 @@ func (client GroupsClient) GetResponder(resp *http.Response) (result ADGroup, er // GetGroupMembers gets the members of a group. // Parameters: // objectID - the object ID of the group whose members should be retrieved. -func (client GroupsClient) GetGroupMembers(ctx context.Context, objectID string) (result GetObjectsResultPage, err error) { - result.fn = func(lastResult GetObjectsResult) (GetObjectsResult, error) { +func (client GroupsClient) GetGroupMembers(ctx context.Context, objectID string) (result DirectoryObjectListResultPage, err error) { + result.fn = func(lastResult DirectoryObjectListResult) (DirectoryObjectListResult, error) { if lastResult.OdataNextLink == nil || len(to.String(lastResult.OdataNextLink)) < 1 { - return GetObjectsResult{}, nil + return DirectoryObjectListResult{}, nil } return client.GetGroupMembersNext(ctx, *lastResult.OdataNextLink) } @@ -337,12 +411,12 @@ func (client GroupsClient) GetGroupMembers(ctx context.Context, objectID string) resp, err := client.GetGroupMembersSender(req) if err != nil { - result.gor.Response = autorest.Response{Response: resp} + result.dolr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembers", resp, "Failure sending request") return } - result.gor, err = client.GetGroupMembersResponder(resp) + result.dolr, err = client.GetGroupMembersResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembers", resp, "Failure responding to request") } @@ -379,7 +453,7 @@ func (client GroupsClient) GetGroupMembersSender(req *http.Request) (*http.Respo // GetGroupMembersResponder handles the response to the GetGroupMembers request. The method always // closes the http.Response Body. -func (client GroupsClient) GetGroupMembersResponder(resp *http.Response) (result GetObjectsResult, err error) { +func (client GroupsClient) GetGroupMembersResponder(resp *http.Response) (result DirectoryObjectListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -391,7 +465,7 @@ func (client GroupsClient) GetGroupMembersResponder(resp *http.Response) (result } // GetGroupMembersComplete enumerates all values, automatically crossing page boundaries as required. -func (client GroupsClient) GetGroupMembersComplete(ctx context.Context, objectID string) (result GetObjectsResultIterator, err error) { +func (client GroupsClient) GetGroupMembersComplete(ctx context.Context, objectID string) (result DirectoryObjectListResultIterator, err error) { result.page, err = client.GetGroupMembers(ctx, objectID) return } @@ -399,7 +473,7 @@ func (client GroupsClient) GetGroupMembersComplete(ctx context.Context, objectID // GetGroupMembersNext gets the members of a group. // Parameters: // nextLink - next link for the list operation. -func (client GroupsClient) GetGroupMembersNext(ctx context.Context, nextLink string) (result GetObjectsResult, err error) { +func (client GroupsClient) GetGroupMembersNext(ctx context.Context, nextLink string) (result DirectoryObjectListResult, err error) { req, err := client.GetGroupMembersNextPreparer(ctx, nextLink) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembersNext", nil, "Failure preparing request") @@ -450,7 +524,7 @@ func (client GroupsClient) GetGroupMembersNextSender(req *http.Request) (*http.R // GetGroupMembersNextResponder handles the response to the GetGroupMembersNext request. The method always // closes the http.Response Body. -func (client GroupsClient) GetGroupMembersNextResponder(resp *http.Response) (result GetObjectsResult, err error) { +func (client GroupsClient) GetGroupMembersNextResponder(resp *http.Response) (result DirectoryObjectListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -753,6 +827,99 @@ func (client GroupsClient) ListNextResponder(resp *http.Response) (result GroupL return } +// ListOwners the owners are a set of non-admin users who are allowed to modify this object. +// Parameters: +// objectID - the object ID of the group for which to get owners. +func (client GroupsClient) ListOwners(ctx context.Context, objectID string) (result DirectoryObjectListResultPage, err error) { + result.fn = client.listOwnersNextResults + req, err := client.ListOwnersPreparer(ctx, objectID) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "ListOwners", nil, "Failure preparing request") + return + } + + resp, err := client.ListOwnersSender(req) + if err != nil { + result.dolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "ListOwners", resp, "Failure sending request") + return + } + + result.dolr, err = client.ListOwnersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "ListOwners", resp, "Failure responding to request") + } + + return +} + +// ListOwnersPreparer prepares the ListOwners request. +func (client GroupsClient) ListOwnersPreparer(ctx context.Context, objectID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "objectId": autorest.Encode("path", objectID), + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/groups/{objectId}/owners", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListOwnersSender sends the ListOwners request. The method will close the +// http.Response Body if it receives an error. +func (client GroupsClient) ListOwnersSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListOwnersResponder handles the response to the ListOwners request. The method always +// closes the http.Response Body. +func (client GroupsClient) ListOwnersResponder(resp *http.Response) (result DirectoryObjectListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listOwnersNextResults retrieves the next set of results, if any. +func (client GroupsClient) listOwnersNextResults(lastResults DirectoryObjectListResult) (result DirectoryObjectListResult, err error) { + req, err := lastResults.directoryObjectListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "listOwnersNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListOwnersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "listOwnersNextResults", resp, "Failure sending next results request") + } + result, err = client.ListOwnersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "listOwnersNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListOwnersComplete enumerates all values, automatically crossing page boundaries as required. +func (client GroupsClient) ListOwnersComplete(ctx context.Context, objectID string) (result DirectoryObjectListResultIterator, err error) { + result.page, err = client.ListOwners(ctx, objectID) + return +} + // RemoveMember remove a member from a group. // Parameters: // groupObjectID - the object ID of the group from which to remove the member. @@ -818,3 +985,69 @@ func (client GroupsClient) RemoveMemberResponder(resp *http.Response) (result au result.Response = resp return } + +// RemoveOwner remove a member from owners. +// Parameters: +// objectID - the object ID of the group from which to remove the owner. +// ownerObjectID - owner object id +func (client GroupsClient) RemoveOwner(ctx context.Context, objectID string, ownerObjectID string) (result autorest.Response, err error) { + req, err := client.RemoveOwnerPreparer(ctx, objectID, ownerObjectID) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "RemoveOwner", nil, "Failure preparing request") + return + } + + resp, err := client.RemoveOwnerSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "RemoveOwner", resp, "Failure sending request") + return + } + + result, err = client.RemoveOwnerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "RemoveOwner", resp, "Failure responding to request") + } + + return +} + +// RemoveOwnerPreparer prepares the RemoveOwner request. +func (client GroupsClient) RemoveOwnerPreparer(ctx context.Context, objectID string, ownerObjectID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "objectId": autorest.Encode("path", objectID), + "ownerObjectId": autorest.Encode("path", ownerObjectID), + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/groups/{objectId}/$links/owners/{ownerObjectId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RemoveOwnerSender sends the RemoveOwner request. The method will close the +// http.Response Body if it receives an error. +func (client GroupsClient) RemoveOwnerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// RemoveOwnerResponder handles the response to the RemoveOwner request. The method always +// closes the http.Response Body. +func (client GroupsClient) RemoveOwnerResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/graphrbac/1.6/graphrbac/models.go b/services/graphrbac/1.6/graphrbac/models.go index aad11b313acb..d378860c999e 100644 --- a/services/graphrbac/1.6/graphrbac/models.go +++ b/services/graphrbac/1.6/graphrbac/models.go @@ -59,114 +59,28 @@ func PossibleUserTypeValues() []UserType { return []UserType{Guest, Member} } -// AADObject the properties of an Active Directory object. -type AADObject struct { - autorest.Response `json:"-"` +// AddOwnerParameters request parameters for adding a owner to an application. +type AddOwnerParameters struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` - // ObjectID - The ID of the object. - ObjectID *string `json:"objectId,omitempty"` - // ObjectType - The type of AAD object. - ObjectType *string `json:"objectType,omitempty"` - // DisplayName - The display name of the object. - DisplayName *string `json:"displayName,omitempty"` - // UserPrincipalName - The principal name of the object. - UserPrincipalName *string `json:"userPrincipalName,omitempty"` - // Mail - The primary email address of the object. - Mail *string `json:"mail,omitempty"` - // MailEnabled - Whether the AAD object is mail-enabled. - MailEnabled *bool `json:"mailEnabled,omitempty"` - // MailNickname - The mail alias for the user. - MailNickname *string `json:"mailNickname,omitempty"` - // SecurityEnabled - Whether the AAD object is security-enabled. - SecurityEnabled *bool `json:"securityEnabled,omitempty"` - // SignInName - The sign-in name of the object. - SignInName *string `json:"signInName,omitempty"` - // ServicePrincipalNames - A collection of service principal names associated with the object. - ServicePrincipalNames *[]string `json:"servicePrincipalNames,omitempty"` - // UserType - The user type of the object. - UserType *string `json:"userType,omitempty"` - // UsageLocation - A two letter country code (ISO standard 3166). Required for users that will be assigned licenses due to legal requirement to check for availability of services in countries. Examples include: "US", "JP", and "GB". - UsageLocation *string `json:"usageLocation,omitempty"` - // AppID - The application ID. - AppID *string `json:"appId,omitempty"` - // AppPermissions - The application permissions. - AppPermissions *[]string `json:"appPermissions,omitempty"` - // AvailableToOtherTenants - Whether the application is be available to other tenants. - AvailableToOtherTenants *bool `json:"availableToOtherTenants,omitempty"` - // IdentifierUris - A collection of URIs for the application. - IdentifierUris *[]string `json:"identifierUris,omitempty"` - // ReplyUrls - A collection of reply URLs for the application. - ReplyUrls *[]string `json:"replyUrls,omitempty"` - // Homepage - The home page of the application. - Homepage *string `json:"homepage,omitempty"` + // URL - A owner object URL, such as "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, application, servicePrincipal, group) to be added. + URL *string `json:"url,omitempty"` } -// MarshalJSON is the custom marshaler for AADObject. -func (ao AADObject) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for AddOwnerParameters. +func (aop AddOwnerParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ao.ObjectID != nil { - objectMap["objectId"] = ao.ObjectID - } - if ao.ObjectType != nil { - objectMap["objectType"] = ao.ObjectType - } - if ao.DisplayName != nil { - objectMap["displayName"] = ao.DisplayName - } - if ao.UserPrincipalName != nil { - objectMap["userPrincipalName"] = ao.UserPrincipalName - } - if ao.Mail != nil { - objectMap["mail"] = ao.Mail - } - if ao.MailEnabled != nil { - objectMap["mailEnabled"] = ao.MailEnabled - } - if ao.MailNickname != nil { - objectMap["mailNickname"] = ao.MailNickname - } - if ao.SecurityEnabled != nil { - objectMap["securityEnabled"] = ao.SecurityEnabled - } - if ao.SignInName != nil { - objectMap["signInName"] = ao.SignInName - } - if ao.ServicePrincipalNames != nil { - objectMap["servicePrincipalNames"] = ao.ServicePrincipalNames - } - if ao.UserType != nil { - objectMap["userType"] = ao.UserType - } - if ao.UsageLocation != nil { - objectMap["usageLocation"] = ao.UsageLocation + if aop.URL != nil { + objectMap["url"] = aop.URL } - if ao.AppID != nil { - objectMap["appId"] = ao.AppID - } - if ao.AppPermissions != nil { - objectMap["appPermissions"] = ao.AppPermissions - } - if ao.AvailableToOtherTenants != nil { - objectMap["availableToOtherTenants"] = ao.AvailableToOtherTenants - } - if ao.IdentifierUris != nil { - objectMap["identifierUris"] = ao.IdentifierUris - } - if ao.ReplyUrls != nil { - objectMap["replyUrls"] = ao.ReplyUrls - } - if ao.Homepage != nil { - objectMap["homepage"] = ao.Homepage - } - for k, v := range ao.AdditionalProperties { + for k, v := range aop.AdditionalProperties { objectMap[k] = v } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for AADObject struct. -func (ao *AADObject) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for AddOwnerParameters struct. +func (aop *AddOwnerParameters) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -181,172 +95,19 @@ func (ao *AADObject) UnmarshalJSON(body []byte) error { if err != nil { return err } - if ao.AdditionalProperties == nil { - ao.AdditionalProperties = make(map[string]interface{}) - } - ao.AdditionalProperties[k] = additionalProperties - } - case "objectId": - if v != nil { - var objectID string - err = json.Unmarshal(*v, &objectID) - if err != nil { - return err - } - ao.ObjectID = &objectID - } - case "objectType": - if v != nil { - var objectType string - err = json.Unmarshal(*v, &objectType) - if err != nil { - return err - } - ao.ObjectType = &objectType - } - case "displayName": - if v != nil { - var displayName string - err = json.Unmarshal(*v, &displayName) - if err != nil { - return err - } - ao.DisplayName = &displayName - } - case "userPrincipalName": - if v != nil { - var userPrincipalName string - err = json.Unmarshal(*v, &userPrincipalName) - if err != nil { - return err - } - ao.UserPrincipalName = &userPrincipalName - } - case "mail": - if v != nil { - var mailVar string - err = json.Unmarshal(*v, &mailVar) - if err != nil { - return err - } - ao.Mail = &mailVar - } - case "mailEnabled": - if v != nil { - var mailEnabled bool - err = json.Unmarshal(*v, &mailEnabled) - if err != nil { - return err - } - ao.MailEnabled = &mailEnabled - } - case "mailNickname": - if v != nil { - var mailNickname string - err = json.Unmarshal(*v, &mailNickname) - if err != nil { - return err + if aop.AdditionalProperties == nil { + aop.AdditionalProperties = make(map[string]interface{}) } - ao.MailNickname = &mailNickname + aop.AdditionalProperties[k] = additionalProperties } - case "securityEnabled": - if v != nil { - var securityEnabled bool - err = json.Unmarshal(*v, &securityEnabled) - if err != nil { - return err - } - ao.SecurityEnabled = &securityEnabled - } - case "signInName": - if v != nil { - var signInName string - err = json.Unmarshal(*v, &signInName) - if err != nil { - return err - } - ao.SignInName = &signInName - } - case "servicePrincipalNames": - if v != nil { - var servicePrincipalNames []string - err = json.Unmarshal(*v, &servicePrincipalNames) - if err != nil { - return err - } - ao.ServicePrincipalNames = &servicePrincipalNames - } - case "userType": - if v != nil { - var userType string - err = json.Unmarshal(*v, &userType) - if err != nil { - return err - } - ao.UserType = &userType - } - case "usageLocation": - if v != nil { - var usageLocation string - err = json.Unmarshal(*v, &usageLocation) - if err != nil { - return err - } - ao.UsageLocation = &usageLocation - } - case "appId": - if v != nil { - var appID string - err = json.Unmarshal(*v, &appID) - if err != nil { - return err - } - ao.AppID = &appID - } - case "appPermissions": - if v != nil { - var appPermissions []string - err = json.Unmarshal(*v, &appPermissions) - if err != nil { - return err - } - ao.AppPermissions = &appPermissions - } - case "availableToOtherTenants": - if v != nil { - var availableToOtherTenants bool - err = json.Unmarshal(*v, &availableToOtherTenants) - if err != nil { - return err - } - ao.AvailableToOtherTenants = &availableToOtherTenants - } - case "identifierUris": - if v != nil { - var identifierUris []string - err = json.Unmarshal(*v, &identifierUris) - if err != nil { - return err - } - ao.IdentifierUris = &identifierUris - } - case "replyUrls": - if v != nil { - var replyUrls []string - err = json.Unmarshal(*v, &replyUrls) - if err != nil { - return err - } - ao.ReplyUrls = &replyUrls - } - case "homepage": + case "url": if v != nil { - var homepage string - err = json.Unmarshal(*v, &homepage) + var URL string + err = json.Unmarshal(*v, &URL) if err != nil { return err } - ao.Homepage = &homepage + aop.URL = &URL } } } @@ -359,6 +120,10 @@ type ADGroup struct { autorest.Response `json:"-"` // DisplayName - The display name of the group. DisplayName *string `json:"displayName,omitempty"` + // MailEnabled - Whether the group is mail-enabled. Must be false. This is because only pure security groups can be created using the Graph API. + MailEnabled *bool `json:"mailEnabled,omitempty"` + // MailNickname - The mail alias for the group. + MailNickname *string `json:"mailNickname,omitempty"` // SecurityEnabled - Whether the group is security-enable. SecurityEnabled *bool `json:"securityEnabled,omitempty"` // Mail - The primary email address of the group. @@ -380,6 +145,12 @@ func (ag ADGroup) MarshalJSON() ([]byte, error) { if ag.DisplayName != nil { objectMap["displayName"] = ag.DisplayName } + if ag.MailEnabled != nil { + objectMap["mailEnabled"] = ag.MailEnabled + } + if ag.MailNickname != nil { + objectMap["mailNickname"] = ag.MailNickname + } if ag.SecurityEnabled != nil { objectMap["securityEnabled"] = ag.SecurityEnabled } @@ -449,6 +220,24 @@ func (ag *ADGroup) UnmarshalJSON(body []byte) error { } ag.DisplayName = &displayName } + case "mailEnabled": + if v != nil { + var mailEnabled bool + err = json.Unmarshal(*v, &mailEnabled) + if err != nil { + return err + } + ag.MailEnabled = &mailEnabled + } + case "mailNickname": + if v != nil { + var mailNickname string + err = json.Unmarshal(*v, &mailNickname) + if err != nil { + return err + } + ag.MailNickname = &mailNickname + } case "securityEnabled": if v != nil { var securityEnabled bool @@ -517,6 +306,8 @@ type Application struct { autorest.Response `json:"-"` // AppID - The application ID. AppID *string `json:"appId,omitempty"` + // AppRoles - The collection of application roles that an application may declare. These roles can be assigned to users, groups or service principals. + AppRoles *[]AppRole `json:"appRoles,omitempty"` // AppPermissions - The application permissions. AppPermissions *[]string `json:"appPermissions,omitempty"` // AvailableToOtherTenants - Whether the application is be available to other tenants. @@ -548,6 +339,9 @@ func (a Application) MarshalJSON() ([]byte, error) { if a.AppID != nil { objectMap["appId"] = a.AppID } + if a.AppRoles != nil { + objectMap["appRoles"] = a.AppRoles + } if a.AppPermissions != nil { objectMap["appPermissions"] = a.AppPermissions } @@ -632,6 +426,15 @@ func (a *Application) UnmarshalJSON(body []byte) error { } a.AppID = &appID } + case "appRoles": + if v != nil { + var appRoles []AppRole + err = json.Unmarshal(*v, &appRoles) + if err != nil { + return err + } + a.AppRoles = &appRoles + } case "appPermissions": if v != nil { var appPermissions []string @@ -740,66 +543,12 @@ func (a *Application) UnmarshalJSON(body []byte) error { return nil } -// ApplicationAddOwnerParameters request parameters for adding a owner to an application. -type ApplicationAddOwnerParameters struct { - // AdditionalProperties - Unmatched properties from the message are deserialized this collection - AdditionalProperties map[string]interface{} `json:""` - // URL - A owner object URL, such as "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner (user, application, servicePrincipal, group) to be added. - URL *string `json:"url,omitempty"` -} - -// MarshalJSON is the custom marshaler for ApplicationAddOwnerParameters. -func (aaop ApplicationAddOwnerParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if aaop.URL != nil { - objectMap["url"] = aaop.URL - } - for k, v := range aaop.AdditionalProperties { - objectMap[k] = v - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ApplicationAddOwnerParameters struct. -func (aaop *ApplicationAddOwnerParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - default: - if v != nil { - var additionalProperties interface{} - err = json.Unmarshal(*v, &additionalProperties) - if err != nil { - return err - } - if aaop.AdditionalProperties == nil { - aaop.AdditionalProperties = make(map[string]interface{}) - } - aaop.AdditionalProperties[k] = additionalProperties - } - case "url": - if v != nil { - var URL string - err = json.Unmarshal(*v, &URL) - if err != nil { - return err - } - aaop.URL = &URL - } - } - } - - return nil -} - // ApplicationCreateParameters request parameters for creating a new application. type ApplicationCreateParameters struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` + // AppRoles - The collection of application roles that an application may declare. These roles can be assigned to users, groups or service principals. + AppRoles *[]AppRole `json:"appRoles,omitempty"` // AvailableToOtherTenants - Whether the application is available to other tenants. AvailableToOtherTenants *bool `json:"availableToOtherTenants,omitempty"` // DisplayName - The display name of the application. @@ -823,6 +572,9 @@ type ApplicationCreateParameters struct { // MarshalJSON is the custom marshaler for ApplicationCreateParameters. func (acp ApplicationCreateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if acp.AppRoles != nil { + objectMap["appRoles"] = acp.AppRoles + } if acp.AvailableToOtherTenants != nil { objectMap["availableToOtherTenants"] = acp.AvailableToOtherTenants } @@ -877,6 +629,15 @@ func (acp *ApplicationCreateParameters) UnmarshalJSON(body []byte) error { } acp.AdditionalProperties[k] = additionalProperties } + case "appRoles": + if v != nil { + var appRoles []AppRole + err = json.Unmarshal(*v, &appRoles) + if err != nil { + return err + } + acp.AppRoles = &appRoles + } case "availableToOtherTenants": if v != nil { var availableToOtherTenants bool @@ -1058,6 +819,8 @@ func (page ApplicationListResultPage) Values() []Application { type ApplicationUpdateParameters struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` + // AppRoles - The collection of application roles that an application may declare. These roles can be assigned to users, groups or service principals. + AppRoles *[]AppRole `json:"appRoles,omitempty"` // AvailableToOtherTenants - Whether the application is available to other tenants AvailableToOtherTenants *bool `json:"availableToOtherTenants,omitempty"` // DisplayName - The display name of the application. @@ -1081,6 +844,9 @@ type ApplicationUpdateParameters struct { // MarshalJSON is the custom marshaler for ApplicationUpdateParameters. func (aup ApplicationUpdateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if aup.AppRoles != nil { + objectMap["appRoles"] = aup.AppRoles + } if aup.AvailableToOtherTenants != nil { objectMap["availableToOtherTenants"] = aup.AvailableToOtherTenants } @@ -1135,6 +901,15 @@ func (aup *ApplicationUpdateParameters) UnmarshalJSON(body []byte) error { } aup.AdditionalProperties[k] = additionalProperties } + case "appRoles": + if v != nil { + var appRoles []AppRole + err = json.Unmarshal(*v, &appRoles) + if err != nil { + return err + } + aup.AppRoles = &appRoles + } case "availableToOtherTenants": if v != nil { var availableToOtherTenants bool @@ -1222,6 +997,22 @@ func (aup *ApplicationUpdateParameters) UnmarshalJSON(body []byte) error { return nil } +// AppRole ... +type AppRole struct { + // ID - Unique role identifier inside the appRoles collection. + ID *string `json:"id,omitempty"` + // AllowedMemberTypes - Specifies whether this app role definition can be assigned to users and groups by setting to 'User', or to other applications (that are accessing this application in daemon service scenarios) by setting to 'Application', or to both. + AllowedMemberTypes *[]string `json:"allowedMemberTypes,omitempty"` + // Description - Permission help text that appears in the admin app assignment and consent experiences. + Description *string `json:"description,omitempty"` + // DisplayName - Display name for the permission that appears in the admin consent and app assignment experiences. + DisplayName *string `json:"displayName,omitempty"` + // IsEnabled - When creating or updating a role definition, this must be set to true (which is the default). To delete a role, this must first be set to false. At that point, in a subsequent call, this role may be removed. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Value - Specifies the value of the roles claim that the application should expect in the authentication and access tokens. + Value *string `json:"value,omitempty"` +} + // CheckGroupMembershipParameters request parameters for IsMemberOf API call. type CheckGroupMembershipParameters struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection @@ -1527,6 +1318,8 @@ type DirectoryObjectListResult struct { autorest.Response `json:"-"` // Value - A collection of DirectoryObject. Value *[]BasicDirectoryObject `json:"value,omitempty"` + // OdataNextLink - The URL to get the next set of results. + OdataNextLink *string `json:"odata.nextLink,omitempty"` } // UnmarshalJSON is the custom unmarshaler for DirectoryObjectListResult struct. @@ -1546,12 +1339,102 @@ func (dolr *DirectoryObjectListResult) UnmarshalJSON(body []byte) error { } dolr.Value = &value } + case "odata.nextLink": + if v != nil { + var odataNextLink string + err = json.Unmarshal(*v, &odataNextLink) + if err != nil { + return err + } + dolr.OdataNextLink = &odataNextLink + } } } return nil } +// DirectoryObjectListResultIterator provides access to a complete listing of DirectoryObject values. +type DirectoryObjectListResultIterator struct { + i int + page DirectoryObjectListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DirectoryObjectListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DirectoryObjectListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DirectoryObjectListResultIterator) Response() DirectoryObjectListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DirectoryObjectListResultIterator) Value() BasicDirectoryObject { + if !iter.page.NotDone() { + return DirectoryObject{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dolr DirectoryObjectListResult) IsEmpty() bool { + return dolr.Value == nil || len(*dolr.Value) == 0 +} + +// DirectoryObjectListResultPage contains a page of BasicDirectoryObject values. +type DirectoryObjectListResultPage struct { + fn func(DirectoryObjectListResult) (DirectoryObjectListResult, error) + dolr DirectoryObjectListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DirectoryObjectListResultPage) Next() error { + next, err := page.fn(page.dolr) + if err != nil { + return err + } + page.dolr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DirectoryObjectListResultPage) NotDone() bool { + return !page.dolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DirectoryObjectListResultPage) Response() DirectoryObjectListResult { + return page.dolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DirectoryObjectListResultPage) Values() []BasicDirectoryObject { + if page.dolr.IsEmpty() { + return nil + } + return *page.dolr.Value +} + // Domain active Directory Domain information. type Domain struct { autorest.Response `json:"-"` @@ -1737,105 +1620,15 @@ func (gop *GetObjectsParameters) UnmarshalJSON(body []byte) error { if v != nil { var includeDirectoryObjectReferences bool err = json.Unmarshal(*v, &includeDirectoryObjectReferences) - if err != nil { - return err - } - gop.IncludeDirectoryObjectReferences = &includeDirectoryObjectReferences - } - } - } - - return nil -} - -// GetObjectsResult the response to an Active Directory object inquiry API request. -type GetObjectsResult struct { - autorest.Response `json:"-"` - // Value - A collection of Active Directory objects. - Value *[]AADObject `json:"value,omitempty"` - // OdataNextLink - The URL to get the next set of results. - OdataNextLink *string `json:"odata.nextLink,omitempty"` -} - -// GetObjectsResultIterator provides access to a complete listing of AADObject values. -type GetObjectsResultIterator struct { - i int - page GetObjectsResultPage -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *GetObjectsResultIterator) Next() error { - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err := iter.page.Next() - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter GetObjectsResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter GetObjectsResultIterator) Response() GetObjectsResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter GetObjectsResultIterator) Value() AADObject { - if !iter.page.NotDone() { - return AADObject{} - } - return iter.page.Values()[iter.i] -} - -// IsEmpty returns true if the ListResult contains no values. -func (gor GetObjectsResult) IsEmpty() bool { - return gor.Value == nil || len(*gor.Value) == 0 -} - -// GetObjectsResultPage contains a page of AADObject values. -type GetObjectsResultPage struct { - fn func(GetObjectsResult) (GetObjectsResult, error) - gor GetObjectsResult -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *GetObjectsResultPage) Next() error { - next, err := page.fn(page.gor) - if err != nil { - return err + if err != nil { + return err + } + gop.IncludeDirectoryObjectReferences = &includeDirectoryObjectReferences + } + } } - page.gor = next - return nil -} -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page GetObjectsResultPage) NotDone() bool { - return !page.gor.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page GetObjectsResultPage) Response() GetObjectsResult { - return page.gor -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page GetObjectsResultPage) Values() []AADObject { - if page.gor.IsEmpty() { - return nil - } - return *page.gor.Value + return nil } // GraphError active Directory error information. @@ -2743,6 +2536,8 @@ type ServicePrincipal struct { DisplayName *string `json:"displayName,omitempty"` // AppID - The application ID. AppID *string `json:"appId,omitempty"` + // AppRoles - The collection of application roles that an application may declare. These roles can be assigned to users, groups or service principals. + AppRoles *[]AppRole `json:"appRoles,omitempty"` // ServicePrincipalNames - A collection of service principal names. ServicePrincipalNames *[]string `json:"servicePrincipalNames,omitempty"` // AdditionalProperties - Unmatched properties from the message are deserialized this collection @@ -2765,6 +2560,9 @@ func (sp ServicePrincipal) MarshalJSON() ([]byte, error) { if sp.AppID != nil { objectMap["appId"] = sp.AppID } + if sp.AppRoles != nil { + objectMap["appRoles"] = sp.AppRoles + } if sp.ServicePrincipalNames != nil { objectMap["servicePrincipalNames"] = sp.ServicePrincipalNames } @@ -2840,6 +2638,15 @@ func (sp *ServicePrincipal) UnmarshalJSON(body []byte) error { } sp.AppID = &appID } + case "appRoles": + if v != nil { + var appRoles []AppRole + err = json.Unmarshal(*v, &appRoles) + if err != nil { + return err + } + sp.AppRoles = &appRoles + } case "servicePrincipalNames": if v != nil { var servicePrincipalNames []string @@ -2898,24 +2705,51 @@ func (sp *ServicePrincipal) UnmarshalJSON(body []byte) error { type ServicePrincipalCreateParameters struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` - // AppID - application Id - AppID *string `json:"appId,omitempty"` // AccountEnabled - Whether the account is enabled AccountEnabled *bool `json:"accountEnabled,omitempty"` + // AppID - application Id + AppID *string `json:"appId,omitempty"` + // AppRoleAssignmentRequired - Specifies whether an AppRoleAssignment to a user or group is required before Azure AD will issue a user or access token to the application. + AppRoleAssignmentRequired *bool `json:"appRoleAssignmentRequired,omitempty"` + // DisplayName - The display name for the service principal. + DisplayName *string `json:"displayName,omitempty"` + ErrorURL *string `json:"errorUrl,omitempty"` + // Homepage - The URL to the homepage of the associated application. + Homepage *string `json:"homepage,omitempty"` // KeyCredentials - A collection of KeyCredential objects. KeyCredentials *[]KeyCredential `json:"keyCredentials,omitempty"` // PasswordCredentials - A collection of PasswordCredential objects PasswordCredentials *[]PasswordCredential `json:"passwordCredentials,omitempty"` + // PublisherName - The display name of the tenant in which the associated application is specified. + PublisherName *string `json:"publisherName,omitempty"` + // ReplyUrls - A collection of reply URLs for the service principal. + ReplyUrls *[]string `json:"replyUrls,omitempty"` + SamlMetadataURL *string `json:"samlMetadataUrl,omitempty"` + // ServicePrincipalNames - A collection of service principal names. + ServicePrincipalNames *[]string `json:"servicePrincipalNames,omitempty"` + Tags *[]string `json:"tags,omitempty"` } // MarshalJSON is the custom marshaler for ServicePrincipalCreateParameters. func (spcp ServicePrincipalCreateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if spcp.AccountEnabled != nil { + objectMap["accountEnabled"] = spcp.AccountEnabled + } if spcp.AppID != nil { objectMap["appId"] = spcp.AppID } - if spcp.AccountEnabled != nil { - objectMap["accountEnabled"] = spcp.AccountEnabled + if spcp.AppRoleAssignmentRequired != nil { + objectMap["appRoleAssignmentRequired"] = spcp.AppRoleAssignmentRequired + } + if spcp.DisplayName != nil { + objectMap["displayName"] = spcp.DisplayName + } + if spcp.ErrorURL != nil { + objectMap["errorUrl"] = spcp.ErrorURL + } + if spcp.Homepage != nil { + objectMap["homepage"] = spcp.Homepage } if spcp.KeyCredentials != nil { objectMap["keyCredentials"] = spcp.KeyCredentials @@ -2923,6 +2757,21 @@ func (spcp ServicePrincipalCreateParameters) MarshalJSON() ([]byte, error) { if spcp.PasswordCredentials != nil { objectMap["passwordCredentials"] = spcp.PasswordCredentials } + if spcp.PublisherName != nil { + objectMap["publisherName"] = spcp.PublisherName + } + if spcp.ReplyUrls != nil { + objectMap["replyUrls"] = spcp.ReplyUrls + } + if spcp.SamlMetadataURL != nil { + objectMap["samlMetadataUrl"] = spcp.SamlMetadataURL + } + if spcp.ServicePrincipalNames != nil { + objectMap["servicePrincipalNames"] = spcp.ServicePrincipalNames + } + if spcp.Tags != nil { + objectMap["tags"] = spcp.Tags + } for k, v := range spcp.AdditionalProperties { objectMap[k] = v } @@ -2950,6 +2799,15 @@ func (spcp *ServicePrincipalCreateParameters) UnmarshalJSON(body []byte) error { } spcp.AdditionalProperties[k] = additionalProperties } + case "accountEnabled": + if v != nil { + var accountEnabled bool + err = json.Unmarshal(*v, &accountEnabled) + if err != nil { + return err + } + spcp.AccountEnabled = &accountEnabled + } case "appId": if v != nil { var appID string @@ -2959,14 +2817,41 @@ func (spcp *ServicePrincipalCreateParameters) UnmarshalJSON(body []byte) error { } spcp.AppID = &appID } - case "accountEnabled": + case "appRoleAssignmentRequired": if v != nil { - var accountEnabled bool - err = json.Unmarshal(*v, &accountEnabled) + var appRoleAssignmentRequired bool + err = json.Unmarshal(*v, &appRoleAssignmentRequired) if err != nil { return err } - spcp.AccountEnabled = &accountEnabled + spcp.AppRoleAssignmentRequired = &appRoleAssignmentRequired + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + spcp.DisplayName = &displayName + } + case "errorUrl": + if v != nil { + var errorURL string + err = json.Unmarshal(*v, &errorURL) + if err != nil { + return err + } + spcp.ErrorURL = &errorURL + } + case "homepage": + if v != nil { + var homepage string + err = json.Unmarshal(*v, &homepage) + if err != nil { + return err + } + spcp.Homepage = &homepage } case "keyCredentials": if v != nil { @@ -2986,6 +2871,51 @@ func (spcp *ServicePrincipalCreateParameters) UnmarshalJSON(body []byte) error { } spcp.PasswordCredentials = &passwordCredentials } + case "publisherName": + if v != nil { + var publisherName string + err = json.Unmarshal(*v, &publisherName) + if err != nil { + return err + } + spcp.PublisherName = &publisherName + } + case "replyUrls": + if v != nil { + var replyUrls []string + err = json.Unmarshal(*v, &replyUrls) + if err != nil { + return err + } + spcp.ReplyUrls = &replyUrls + } + case "samlMetadataUrl": + if v != nil { + var samlMetadataURL string + err = json.Unmarshal(*v, &samlMetadataURL) + if err != nil { + return err + } + spcp.SamlMetadataURL = &samlMetadataURL + } + case "servicePrincipalNames": + if v != nil { + var servicePrincipalNames []string + err = json.Unmarshal(*v, &servicePrincipalNames) + if err != nil { + return err + } + spcp.ServicePrincipalNames = &servicePrincipalNames + } + case "tags": + if v != nil { + var tags []string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + spcp.Tags = &tags + } } } @@ -3082,6 +3012,227 @@ func (page ServicePrincipalListResultPage) Values() []ServicePrincipal { return *page.splr.Value } +// ServicePrincipalUpdateParameters request parameters for creating a new service principal. +type ServicePrincipalUpdateParameters struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // AccountEnabled - Whether the account is enabled + AccountEnabled *bool `json:"accountEnabled,omitempty"` + // AppID - application Id + AppID *string `json:"appId,omitempty"` + // AppRoleAssignmentRequired - Specifies whether an AppRoleAssignment to a user or group is required before Azure AD will issue a user or access token to the application. + AppRoleAssignmentRequired *bool `json:"appRoleAssignmentRequired,omitempty"` + // DisplayName - The display name for the service principal. + DisplayName *string `json:"displayName,omitempty"` + ErrorURL *string `json:"errorUrl,omitempty"` + // Homepage - The URL to the homepage of the associated application. + Homepage *string `json:"homepage,omitempty"` + // KeyCredentials - A collection of KeyCredential objects. + KeyCredentials *[]KeyCredential `json:"keyCredentials,omitempty"` + // PasswordCredentials - A collection of PasswordCredential objects + PasswordCredentials *[]PasswordCredential `json:"passwordCredentials,omitempty"` + // PublisherName - The display name of the tenant in which the associated application is specified. + PublisherName *string `json:"publisherName,omitempty"` + // ReplyUrls - A collection of reply URLs for the service principal. + ReplyUrls *[]string `json:"replyUrls,omitempty"` + SamlMetadataURL *string `json:"samlMetadataUrl,omitempty"` + // ServicePrincipalNames - A collection of service principal names. + ServicePrincipalNames *[]string `json:"servicePrincipalNames,omitempty"` + Tags *[]string `json:"tags,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrincipalUpdateParameters. +func (spup ServicePrincipalUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spup.AccountEnabled != nil { + objectMap["accountEnabled"] = spup.AccountEnabled + } + if spup.AppID != nil { + objectMap["appId"] = spup.AppID + } + if spup.AppRoleAssignmentRequired != nil { + objectMap["appRoleAssignmentRequired"] = spup.AppRoleAssignmentRequired + } + if spup.DisplayName != nil { + objectMap["displayName"] = spup.DisplayName + } + if spup.ErrorURL != nil { + objectMap["errorUrl"] = spup.ErrorURL + } + if spup.Homepage != nil { + objectMap["homepage"] = spup.Homepage + } + if spup.KeyCredentials != nil { + objectMap["keyCredentials"] = spup.KeyCredentials + } + if spup.PasswordCredentials != nil { + objectMap["passwordCredentials"] = spup.PasswordCredentials + } + if spup.PublisherName != nil { + objectMap["publisherName"] = spup.PublisherName + } + if spup.ReplyUrls != nil { + objectMap["replyUrls"] = spup.ReplyUrls + } + if spup.SamlMetadataURL != nil { + objectMap["samlMetadataUrl"] = spup.SamlMetadataURL + } + if spup.ServicePrincipalNames != nil { + objectMap["servicePrincipalNames"] = spup.ServicePrincipalNames + } + if spup.Tags != nil { + objectMap["tags"] = spup.Tags + } + for k, v := range spup.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServicePrincipalUpdateParameters struct. +func (spup *ServicePrincipalUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if spup.AdditionalProperties == nil { + spup.AdditionalProperties = make(map[string]interface{}) + } + spup.AdditionalProperties[k] = additionalProperties + } + case "accountEnabled": + if v != nil { + var accountEnabled bool + err = json.Unmarshal(*v, &accountEnabled) + if err != nil { + return err + } + spup.AccountEnabled = &accountEnabled + } + case "appId": + if v != nil { + var appID string + err = json.Unmarshal(*v, &appID) + if err != nil { + return err + } + spup.AppID = &appID + } + case "appRoleAssignmentRequired": + if v != nil { + var appRoleAssignmentRequired bool + err = json.Unmarshal(*v, &appRoleAssignmentRequired) + if err != nil { + return err + } + spup.AppRoleAssignmentRequired = &appRoleAssignmentRequired + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + spup.DisplayName = &displayName + } + case "errorUrl": + if v != nil { + var errorURL string + err = json.Unmarshal(*v, &errorURL) + if err != nil { + return err + } + spup.ErrorURL = &errorURL + } + case "homepage": + if v != nil { + var homepage string + err = json.Unmarshal(*v, &homepage) + if err != nil { + return err + } + spup.Homepage = &homepage + } + case "keyCredentials": + if v != nil { + var keyCredentials []KeyCredential + err = json.Unmarshal(*v, &keyCredentials) + if err != nil { + return err + } + spup.KeyCredentials = &keyCredentials + } + case "passwordCredentials": + if v != nil { + var passwordCredentials []PasswordCredential + err = json.Unmarshal(*v, &passwordCredentials) + if err != nil { + return err + } + spup.PasswordCredentials = &passwordCredentials + } + case "publisherName": + if v != nil { + var publisherName string + err = json.Unmarshal(*v, &publisherName) + if err != nil { + return err + } + spup.PublisherName = &publisherName + } + case "replyUrls": + if v != nil { + var replyUrls []string + err = json.Unmarshal(*v, &replyUrls) + if err != nil { + return err + } + spup.ReplyUrls = &replyUrls + } + case "samlMetadataUrl": + if v != nil { + var samlMetadataURL string + err = json.Unmarshal(*v, &samlMetadataURL) + if err != nil { + return err + } + spup.SamlMetadataURL = &samlMetadataURL + } + case "servicePrincipalNames": + if v != nil { + var servicePrincipalNames []string + err = json.Unmarshal(*v, &servicePrincipalNames) + if err != nil { + return err + } + spup.ServicePrincipalNames = &servicePrincipalNames + } + case "tags": + if v != nil { + var tags []string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + spup.Tags = &tags + } + } + } + + return nil +} + // SignInName contains information about a sign-in name of a local account user in an Azure Active Directory B2C // tenant. type SignInName struct { diff --git a/services/graphrbac/1.6/graphrbac/oauth2.go b/services/graphrbac/1.6/graphrbac/oauth2.go index 97d465bf13b2..38735ad285fb 100644 --- a/services/graphrbac/1.6/graphrbac/oauth2.go +++ b/services/graphrbac/1.6/graphrbac/oauth2.go @@ -106,33 +106,33 @@ func (client OAuth2Client) GetResponder(resp *http.Response) (result Permissions return } -// Post grants OAuth2 permissions for the relevant resource Ids of an app. +// Grant grants OAuth2 permissions for the relevant resource Ids of an app. // Parameters: // body - the relevant app Service Principal Object Id and the Service Principal Objecit Id you want to grant. -func (client OAuth2Client) Post(ctx context.Context, body *Permissions) (result Permissions, err error) { - req, err := client.PostPreparer(ctx, body) +func (client OAuth2Client) Grant(ctx context.Context, body *Permissions) (result Permissions, err error) { + req, err := client.GrantPreparer(ctx, body) if err != nil { - err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Post", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Grant", nil, "Failure preparing request") return } - resp, err := client.PostSender(req) + resp, err := client.GrantSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Post", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Grant", resp, "Failure sending request") return } - result, err = client.PostResponder(resp) + result, err = client.GrantResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Post", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Grant", resp, "Failure responding to request") } return } -// PostPreparer prepares the Post request. -func (client OAuth2Client) PostPreparer(ctx context.Context, body *Permissions) (*http.Request, error) { +// GrantPreparer prepares the Grant request. +func (client OAuth2Client) GrantPreparer(ctx context.Context, body *Permissions) (*http.Request, error) { pathParameters := map[string]interface{}{ "tenantID": autorest.Encode("path", client.TenantID), } @@ -155,16 +155,16 @@ func (client OAuth2Client) PostPreparer(ctx context.Context, body *Permissions) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// PostSender sends the Post request. The method will close the +// GrantSender sends the Grant request. The method will close the // http.Response Body if it receives an error. -func (client OAuth2Client) PostSender(req *http.Request) (*http.Response, error) { +func (client OAuth2Client) GrantSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) } -// PostResponder handles the response to the Post request. The method always +// GrantResponder handles the response to the Grant request. The method always // closes the http.Response Body. -func (client OAuth2Client) PostResponder(resp *http.Response) (result Permissions, err error) { +func (client OAuth2Client) GrantResponder(resp *http.Response) (result Permissions, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/graphrbac/1.6/graphrbac/objects.go b/services/graphrbac/1.6/graphrbac/objects.go index 638a0f02a183..7dc12ba2f3b0 100644 --- a/services/graphrbac/1.6/graphrbac/objects.go +++ b/services/graphrbac/1.6/graphrbac/objects.go @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/autorest/validation" "net/http" ) @@ -41,81 +40,14 @@ func NewObjectsClientWithBaseURI(baseURI string, tenantID string) ObjectsClient return ObjectsClient{NewWithBaseURI(baseURI, tenantID)} } -// GetCurrentUser gets the details for the currently logged-in user. -func (client ObjectsClient) GetCurrentUser(ctx context.Context) (result AADObject, err error) { - req, err := client.GetCurrentUserPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", nil, "Failure preparing request") - return - } - - resp, err := client.GetCurrentUserSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", resp, "Failure sending request") - return - } - - result, err = client.GetCurrentUserResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", resp, "Failure responding to request") - } - - return -} - -// GetCurrentUserPreparer prepares the GetCurrentUser request. -func (client ObjectsClient) GetCurrentUserPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tenantID": autorest.Encode("path", client.TenantID), - } - - const APIVersion = "1.6" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{tenantID}/me", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetCurrentUserSender sends the GetCurrentUser request. The method will close the -// http.Response Body if it receives an error. -func (client ObjectsClient) GetCurrentUserSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetCurrentUserResponder handles the response to the GetCurrentUser request. The method always -// closes the http.Response Body. -func (client ObjectsClient) GetCurrentUserResponder(resp *http.Response) (result AADObject, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetObjectsByObjectIds gets AD group membership for the specified AD object IDs. +// GetObjectsByObjectIds gets the directory objects specified in a list of object IDs. You can also specify which +// resource collections (users, groups, etc.) should be searched by specifying the optional types parameter. // Parameters: // parameters - objects filtering parameters. -func (client ObjectsClient) GetObjectsByObjectIds(ctx context.Context, parameters GetObjectsParameters) (result GetObjectsResultPage, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.IncludeDirectoryObjectReferences", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("graphrbac.ObjectsClient", "GetObjectsByObjectIds", err.Error()) - } - - result.fn = func(lastResult GetObjectsResult) (GetObjectsResult, error) { +func (client ObjectsClient) GetObjectsByObjectIds(ctx context.Context, parameters GetObjectsParameters) (result DirectoryObjectListResultPage, err error) { + result.fn = func(lastResult DirectoryObjectListResult) (DirectoryObjectListResult, error) { if lastResult.OdataNextLink == nil || len(to.String(lastResult.OdataNextLink)) < 1 { - return GetObjectsResult{}, nil + return DirectoryObjectListResult{}, nil } return client.GetObjectsByObjectIdsNext(ctx, *lastResult.OdataNextLink) } @@ -127,12 +59,12 @@ func (client ObjectsClient) GetObjectsByObjectIds(ctx context.Context, parameter resp, err := client.GetObjectsByObjectIdsSender(req) if err != nil { - result.gor.Response = autorest.Response{Response: resp} + result.dolr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", resp, "Failure sending request") return } - result.gor, err = client.GetObjectsByObjectIdsResponder(resp) + result.dolr, err = client.GetObjectsByObjectIdsResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", resp, "Failure responding to request") } @@ -170,7 +102,7 @@ func (client ObjectsClient) GetObjectsByObjectIdsSender(req *http.Request) (*htt // GetObjectsByObjectIdsResponder handles the response to the GetObjectsByObjectIds request. The method always // closes the http.Response Body. -func (client ObjectsClient) GetObjectsByObjectIdsResponder(resp *http.Response) (result GetObjectsResult, err error) { +func (client ObjectsClient) GetObjectsByObjectIdsResponder(resp *http.Response) (result DirectoryObjectListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -182,7 +114,7 @@ func (client ObjectsClient) GetObjectsByObjectIdsResponder(resp *http.Response) } // GetObjectsByObjectIdsComplete enumerates all values, automatically crossing page boundaries as required. -func (client ObjectsClient) GetObjectsByObjectIdsComplete(ctx context.Context, parameters GetObjectsParameters) (result GetObjectsResultIterator, err error) { +func (client ObjectsClient) GetObjectsByObjectIdsComplete(ctx context.Context, parameters GetObjectsParameters) (result DirectoryObjectListResultIterator, err error) { result.page, err = client.GetObjectsByObjectIds(ctx, parameters) return } @@ -190,7 +122,7 @@ func (client ObjectsClient) GetObjectsByObjectIdsComplete(ctx context.Context, p // GetObjectsByObjectIdsNext gets AD group membership for the specified AD object IDs. // Parameters: // nextLink - next link for the list operation. -func (client ObjectsClient) GetObjectsByObjectIdsNext(ctx context.Context, nextLink string) (result GetObjectsResult, err error) { +func (client ObjectsClient) GetObjectsByObjectIdsNext(ctx context.Context, nextLink string) (result DirectoryObjectListResult, err error) { req, err := client.GetObjectsByObjectIdsNextPreparer(ctx, nextLink) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIdsNext", nil, "Failure preparing request") @@ -241,7 +173,7 @@ func (client ObjectsClient) GetObjectsByObjectIdsNextSender(req *http.Request) ( // GetObjectsByObjectIdsNextResponder handles the response to the GetObjectsByObjectIdsNext request. The method always // closes the http.Response Body. -func (client ObjectsClient) GetObjectsByObjectIdsNextResponder(resp *http.Response) (result GetObjectsResult, err error) { +func (client ObjectsClient) GetObjectsByObjectIdsNextResponder(resp *http.Response) (result DirectoryObjectListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/graphrbac/1.6/graphrbac/serviceprincipals.go b/services/graphrbac/1.6/graphrbac/serviceprincipals.go index 2b09eaf96dc7..9ff609a0e532 100644 --- a/services/graphrbac/1.6/graphrbac/serviceprincipals.go +++ b/services/graphrbac/1.6/graphrbac/serviceprincipals.go @@ -47,8 +47,7 @@ func NewServicePrincipalsClientWithBaseURI(baseURI string, tenantID string) Serv func (client ServicePrincipalsClient) Create(ctx context.Context, parameters ServicePrincipalCreateParameters) (result ServicePrincipal, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.AppID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.AccountEnabled", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + Constraints: []validation.Constraint{{Target: "parameters.AppID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewError("graphrbac.ServicePrincipalsClient", "Create", err.Error()) } @@ -455,7 +454,8 @@ func (client ServicePrincipalsClient) ListNextResponder(resp *http.Response) (re // ListOwners the owners are a set of non-admin users who are allowed to modify this object. // Parameters: // objectID - the object ID of the service principal for which to get owners. -func (client ServicePrincipalsClient) ListOwners(ctx context.Context, objectID string) (result DirectoryObjectListResult, err error) { +func (client ServicePrincipalsClient) ListOwners(ctx context.Context, objectID string) (result DirectoryObjectListResultPage, err error) { + result.fn = client.listOwnersNextResults req, err := client.ListOwnersPreparer(ctx, objectID) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListOwners", nil, "Failure preparing request") @@ -464,12 +464,12 @@ func (client ServicePrincipalsClient) ListOwners(ctx context.Context, objectID s resp, err := client.ListOwnersSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.dolr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListOwners", resp, "Failure sending request") return } - result, err = client.ListOwnersResponder(resp) + result.dolr, err = client.ListOwnersResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListOwners", resp, "Failure responding to request") } @@ -517,6 +517,33 @@ func (client ServicePrincipalsClient) ListOwnersResponder(resp *http.Response) ( return } +// listOwnersNextResults retrieves the next set of results, if any. +func (client ServicePrincipalsClient) listOwnersNextResults(lastResults DirectoryObjectListResult) (result DirectoryObjectListResult, err error) { + req, err := lastResults.directoryObjectListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "listOwnersNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListOwnersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "listOwnersNextResults", resp, "Failure sending next results request") + } + result, err = client.ListOwnersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "listOwnersNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListOwnersComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServicePrincipalsClient) ListOwnersComplete(ctx context.Context, objectID string) (result DirectoryObjectListResultIterator, err error) { + result.page, err = client.ListOwners(ctx, objectID) + return +} + // ListPasswordCredentials gets the passwordCredentials associated with a service principal. // Parameters: // objectID - the object ID of the service principal. @@ -582,6 +609,73 @@ func (client ServicePrincipalsClient) ListPasswordCredentialsResponder(resp *htt return } +// Update updates a service principal in the directory. +// Parameters: +// objectID - the object ID of the service principal to delete. +// parameters - parameters to update a service principal. +func (client ServicePrincipalsClient) Update(ctx context.Context, objectID string, parameters ServicePrincipalUpdateParameters) (result autorest.Response, err error) { + req, err := client.UpdatePreparer(ctx, objectID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServicePrincipalsClient) UpdatePreparer(ctx context.Context, objectID string, parameters ServicePrincipalUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "objectId": autorest.Encode("path", objectID), + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/servicePrincipals/{objectId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServicePrincipalsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServicePrincipalsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // UpdateKeyCredentials update the keyCredentials associated with a service principal. // Parameters: // objectID - the object ID for which to get service principal information. diff --git a/services/graphrbac/1.6/graphrbac/signedinuser.go b/services/graphrbac/1.6/graphrbac/signedinuser.go new file mode 100644 index 000000000000..f459f00398c5 --- /dev/null +++ b/services/graphrbac/1.6/graphrbac/signedinuser.go @@ -0,0 +1,242 @@ +package graphrbac + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// SignedInUserClient is the the Graph RBAC Management Client +type SignedInUserClient struct { + BaseClient +} + +// NewSignedInUserClient creates an instance of the SignedInUserClient client. +func NewSignedInUserClient(tenantID string) SignedInUserClient { + return NewSignedInUserClientWithBaseURI(DefaultBaseURI, tenantID) +} + +// NewSignedInUserClientWithBaseURI creates an instance of the SignedInUserClient client. +func NewSignedInUserClientWithBaseURI(baseURI string, tenantID string) SignedInUserClient { + return SignedInUserClient{NewWithBaseURI(baseURI, tenantID)} +} + +// Get gets the details for the currently logged-in user. +func (client SignedInUserClient) Get(ctx context.Context) (result User, err error) { + req, err := client.GetPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SignedInUserClient) GetPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/me", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SignedInUserClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SignedInUserClient) GetResponder(resp *http.Response) (result User, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListOwnedObjects get the list of directory objects that are owned by the user. +func (client SignedInUserClient) ListOwnedObjects(ctx context.Context) (result DirectoryObjectListResultPage, err error) { + result.fn = func(lastResult DirectoryObjectListResult) (DirectoryObjectListResult, error) { + if lastResult.OdataNextLink == nil || len(to.String(lastResult.OdataNextLink)) < 1 { + return DirectoryObjectListResult{}, nil + } + return client.ListOwnedObjectsNext(ctx, *lastResult.OdataNextLink) + } + req, err := client.ListOwnedObjectsPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "ListOwnedObjects", nil, "Failure preparing request") + return + } + + resp, err := client.ListOwnedObjectsSender(req) + if err != nil { + result.dolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "ListOwnedObjects", resp, "Failure sending request") + return + } + + result.dolr, err = client.ListOwnedObjectsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "ListOwnedObjects", resp, "Failure responding to request") + } + + return +} + +// ListOwnedObjectsPreparer prepares the ListOwnedObjects request. +func (client SignedInUserClient) ListOwnedObjectsPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/me/ownedObjects", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListOwnedObjectsSender sends the ListOwnedObjects request. The method will close the +// http.Response Body if it receives an error. +func (client SignedInUserClient) ListOwnedObjectsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListOwnedObjectsResponder handles the response to the ListOwnedObjects request. The method always +// closes the http.Response Body. +func (client SignedInUserClient) ListOwnedObjectsResponder(resp *http.Response) (result DirectoryObjectListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListOwnedObjectsComplete enumerates all values, automatically crossing page boundaries as required. +func (client SignedInUserClient) ListOwnedObjectsComplete(ctx context.Context) (result DirectoryObjectListResultIterator, err error) { + result.page, err = client.ListOwnedObjects(ctx) + return +} + +// ListOwnedObjectsNext get the list of directory objects that are owned by the user. +// Parameters: +// nextLink - next link for the list operation. +func (client SignedInUserClient) ListOwnedObjectsNext(ctx context.Context, nextLink string) (result DirectoryObjectListResult, err error) { + req, err := client.ListOwnedObjectsNextPreparer(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "ListOwnedObjectsNext", nil, "Failure preparing request") + return + } + + resp, err := client.ListOwnedObjectsNextSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "ListOwnedObjectsNext", resp, "Failure sending request") + return + } + + result, err = client.ListOwnedObjectsNextResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.SignedInUserClient", "ListOwnedObjectsNext", resp, "Failure responding to request") + } + + return +} + +// ListOwnedObjectsNextPreparer prepares the ListOwnedObjectsNext request. +func (client SignedInUserClient) ListOwnedObjectsNextPreparer(ctx context.Context, nextLink string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "nextLink": nextLink, + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/{nextLink}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListOwnedObjectsNextSender sends the ListOwnedObjectsNext request. The method will close the +// http.Response Body if it receives an error. +func (client SignedInUserClient) ListOwnedObjectsNextSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListOwnedObjectsNextResponder handles the response to the ListOwnedObjectsNext request. The method always +// closes the http.Response Body. +func (client SignedInUserClient) ListOwnedObjectsNextResponder(resp *http.Response) (result DirectoryObjectListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}