diff --git a/Gopkg.lock b/Gopkg.lock index 8ccb75b62f71..469c02d69da8 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,6 +2,7 @@ [[projects]] + digest = "1:aabb277969c1450d3749ba42cbbc1235f83da7505103e444638b5c50ebb0e6ad" name = "github.com/Azure/go-autorest" packages = [ "autorest", @@ -10,52 +11,64 @@ "autorest/azure/auth", "autorest/date", "autorest/to", - "autorest/validation" + "autorest/validation", ] + pruneopts = "" revision = "4de44cd533576f3c7b44dcb08dc03754d217144d" version = "v10.9.2" [[projects]] + digest = "1:6098222470fe0172157ce9bbef5d2200df4edde17ee649c5d6e48330e4afa4c6" name = "github.com/dgrijalva/jwt-go" packages = ["."] + pruneopts = "" revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e" version = "v3.2.0" [[projects]] branch = "master" + digest = "1:654ac9799e7a8a586d8690bb2229a4f3408bbfe2c5494bf4dfe043053eeb5496" name = "github.com/dimchansky/utfbom" packages = ["."] + pruneopts = "" revision = "6c6132ff69f0f6c088739067407b5d32c52e1d0f" [[projects]] branch = "master" + digest = "1:b2d7ddf0e7f09e6468da25f27d3a17812e150345cd790da5578b05fcf92d2f31" name = "github.com/dnaeon/go-vcr" packages = [ "cassette", - "recorder" + "recorder", ] + pruneopts = "" revision = "f8a7e8b9c630b486df74145bb887793a1b85459b" [[projects]] + digest = "1:eb53021a8aa3f599d29c7102e65026242bdedce998a54837dc67f14b6a97c5fd" name = "github.com/fsnotify/fsnotify" packages = ["."] + pruneopts = "" revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" version = "v1.4.7" [[projects]] branch = "master" + digest = "1:d9cf334ee84f60ea8855a530f09ce9d7b81880ca35bb76b255b5d72ceb11f8bb" name = "github.com/globalsign/mgo" packages = [ ".", "bson", "internal/json", "internal/sasl", - "internal/scram" + "internal/scram", ] + pruneopts = "" revision = "efe0945164a7e582241f37ae8983c075f8f2e870" [[projects]] branch = "master" + digest = "1:9b7c5846d70f425d7fe279595e32a20994c6075e87be03b5c367ed07280877c5" name = "github.com/hashicorp/hcl" packages = [ ".", @@ -67,131 +80,171 @@ "hcl/token", "json/parser", "json/scanner", - "json/token" + "json/token", ] + pruneopts = "" revision = "ef8a98b0bbce4a65b5aa4c368430a80ddc533168" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:961dc3b1d11f969370533390fdf203813162980c858e1dabe827b60940c909a5" name = "github.com/magiconair/properties" packages = ["."] + pruneopts = "" revision = "c2353362d570a7bfa228149c62842019201cfb71" version = "v1.8.0" [[projects]] + digest = "1:71a28fe7d86ace8e51192c97eb4fd376c27ae0ed3a6ff46b41a6da76a0785d78" name = "github.com/marstr/collection" packages = ["."] + pruneopts = "" revision = "871b1cfa2ab97d3d8f54a034280907896190c346" version = "v0.3.3" [[projects]] branch = "master" + digest = "1:5a07891ac7651f2b0db3ca615f88ca80e38a41c0c9f60a6fb123b8cbe3d8d386" name = "github.com/marstr/goalias" packages = ["model"] + pruneopts = "" revision = "8dff9a14db648bfdd58d45515d3eaaee23aad078" [[projects]] + digest = "1:f95025d583786875a71183888acc9d0987fc96f12d4f5afab3d7558797ea1c5a" name = "github.com/marstr/guid" packages = ["."] + pruneopts = "" revision = "8bd9a64bf37eb297b492a4101fb28e80ac0b290f" version = "v1.1.0" [[projects]] branch = "master" + digest = "1:9b1c51ad4f41e364bee3c3281267a73c783711018edd0fd8104268f8782352ad" name = "github.com/marstr/randname" packages = ["."] + pruneopts = "" revision = "3ef1f47af99e66171417047e6f6fa334345e95e7" [[projects]] branch = "master" + digest = "1:99651e95333755cbe5c9768c1b80031300acca64a80870b40309202b32585a5a" name = "github.com/mitchellh/go-homedir" packages = ["."] + pruneopts = "" revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66" [[projects]] branch = "master" + digest = "1:eb9117392ee8e7aa44f78e0db603f70b1050ee0ebda4bd40040befb5b218c546" name = "github.com/mitchellh/mapstructure" packages = ["."] + pruneopts = "" revision = "bb74f1db0675b241733089d5a1faa5dd8b0ef57b" [[projects]] + digest = "1:d60cfeee185019d4fcd35e8c89c83aff576e4723b6100300bf67b05be961388f" name = "github.com/pelletier/go-toml" packages = ["."] + pruneopts = "" revision = "acdc4509485b587f5e675510c4f2c63e90ff68a8" version = "v1.1.0" [[projects]] + digest = "1:7f569d906bdd20d906b606415b7d794f798f91a62fcfb6a4daa6d50690fb7a3f" name = "github.com/satori/go.uuid" packages = ["."] + pruneopts = "" revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3" version = "v1.2.0" [[projects]] + digest = "1:69240630f5a4a6f16a7d6111884e206b0c5b0a233c9ee5fe54956f06c2fd6ac0" name = "github.com/shopspring/decimal" packages = ["."] + pruneopts = "" revision = "69b3a8ad1f5f2c8bd855cb6506d18593064a346b" version = "1.0.1" [[projects]] + digest = "1:d3e2e29bc7342053edc85e1ad751275694a96d58516f749cf3413db1a0eca2ba" name = "github.com/spf13/afero" packages = [ ".", - "mem" + "mem", ] + pruneopts = "" revision = "63644898a8da0bc22138abf860edaf5277b6102e" version = "v1.1.0" [[projects]] + digest = "1:d0b38ba6da419a6d4380700218eeec8623841d44a856bb57369c172fbf692ab4" name = "github.com/spf13/cast" packages = ["."] + pruneopts = "" revision = "8965335b8c7107321228e3e3702cab9832751bac" version = "v1.2.0" [[projects]] + digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6" name = "github.com/spf13/cobra" packages = ["."] + pruneopts = "" revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" version = "v0.0.3" [[projects]] branch = "master" + digest = "1:104517520aab91164020ab6524a5d6b7cafc641b2e42ac6236f6ac1deac4f66a" name = "github.com/spf13/jwalterweatherman" packages = ["."] + pruneopts = "" revision = "7c0cea34c8ece3fbeb2b27ab9b59511d360fb394" [[projects]] + digest = "1:8e243c568f36b09031ec18dff5f7d2769dcf5ca4d624ea511c8e3197dc3d352d" name = "github.com/spf13/pflag" packages = ["."] + pruneopts = "" revision = "583c0c0531f06d5278b7d917446061adc344b5cd" version = "v1.0.1" [[projects]] + digest = "1:3dab237cd3263a290d771d133fed777bb56c22e380b00ebe92e6531d5c8d3d0c" name = "github.com/spf13/viper" packages = ["."] + pruneopts = "" revision = "b5e8006cbee93ec955a89ab31e0e3ce3204f3736" version = "v1.0.2" [[projects]] branch = "master" + digest = "1:e3df40bd62d81f343751b61516cc96a74c8b2a5f4581c9a1a290439816b6f13b" name = "golang.org/x/crypto" packages = [ "pkcs12", - "pkcs12/internal/rc2" + "pkcs12/internal/rc2", ] + pruneopts = "" revision = "5ba7f63082460102a45837dbd1827e10f9479ac0" [[projects]] branch = "master" + digest = "1:bc468e6f6fb109d22b8aa37b1eb9f8e705ebdbe7f462034cfcb72ac73e41b375" name = "golang.org/x/sys" packages = ["unix"] + pruneopts = "" revision = "c11f84a56e43e20a78cee75a7c034031ecf57d1f" [[projects]] + digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4" name = "golang.org/x/text" packages = [ "internal/gen", @@ -199,36 +252,66 @@ "internal/ucd", "transform", "unicode/cldr", - "unicode/norm" + "unicode/norm", ] + pruneopts = "" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] branch = "master" + digest = "1:17418952b3f7a2335f7481086d69dc2e5f4dccaa20da6059c18e565f90a0ea6d" name = "golang.org/x/tools" packages = [ "go/ast/astutil", "imports", - "internal/fastwalk" + "internal/fastwalk", ] + pruneopts = "" revision = "a5b4c53f6e8bdcafa95a94671bf2d1203365858b" [[projects]] branch = "v1" + digest = "1:e75566abfb876e81f00290ec153ff994c33bf8886134c1a38a9a9df5c15a2045" name = "gopkg.in/check.v1" packages = ["."] + pruneopts = "" revision = "20d25e2804050c1cd24a7eea1e7a6447dd0e74ec" [[projects]] + digest = "1:f0620375dd1f6251d9973b5f2596228cc8042e887cd7f827e4220bc1ce8c30e2" name = "gopkg.in/yaml.v2" packages = ["."] + pruneopts = "" revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" version = "v2.2.1" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "3ba7e7e6599059a0ac88f854eca95495c02501ebe2e0be13b38e4f2b823d5c53" + input-imports = [ + "github.com/Azure/go-autorest/autorest", + "github.com/Azure/go-autorest/autorest/adal", + "github.com/Azure/go-autorest/autorest/azure", + "github.com/Azure/go-autorest/autorest/azure/auth", + "github.com/Azure/go-autorest/autorest/date", + "github.com/Azure/go-autorest/autorest/to", + "github.com/Azure/go-autorest/autorest/validation", + "github.com/dnaeon/go-vcr/cassette", + "github.com/dnaeon/go-vcr/recorder", + "github.com/globalsign/mgo", + "github.com/marstr/collection", + "github.com/marstr/goalias/model", + "github.com/marstr/guid", + "github.com/marstr/randname", + "github.com/mitchellh/go-homedir", + "github.com/satori/go.uuid", + "github.com/shopspring/decimal", + "github.com/spf13/cobra", + "github.com/spf13/viper", + "golang.org/x/crypto/pkcs12", + "golang.org/x/tools/imports", + "gopkg.in/check.v1", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/profiles/latest/graphrbac/graphrbac/models.go b/profiles/latest/graphrbac/graphrbac/models.go index 465433b526d5..f4b4e54715f6 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 @@ -84,6 +85,7 @@ type PasswordCredential = original.PasswordCredential type PasswordCredentialListResult = original.PasswordCredentialListResult type PasswordCredentialsUpdateParameters = original.PasswordCredentialsUpdateParameters type PasswordProfile = original.PasswordProfile +type Permissions = original.Permissions type RequiredResourceAccess = original.RequiredResourceAccess type ResourceAccess = original.ResourceAccess type ServicePrincipal = original.ServicePrincipal @@ -101,6 +103,7 @@ type UserListResult = original.UserListResult type UserListResultIterator = original.UserListResultIterator type UserListResultPage = original.UserListResultPage type UserUpdateParameters = original.UserUpdateParameters +type OAuth2Client = original.OAuth2Client type ObjectsClient = original.ObjectsClient type ServicePrincipalsClient = original.ServicePrincipalsClient type UsersClient = original.UsersClient @@ -117,6 +120,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) } @@ -135,6 +144,12 @@ func PossibleObjectTypeValues() []ObjectType { func PossibleUserTypeValues() []UserType { return original.PossibleUserTypeValues() } +func NewOAuth2Client(tenantID string) OAuth2Client { + return original.NewOAuth2Client(tenantID) +} +func NewOAuth2ClientWithBaseURI(baseURI string, tenantID string) OAuth2Client { + return original.NewOAuth2ClientWithBaseURI(baseURI, tenantID) +} func NewObjectsClient(tenantID string) ObjectsClient { return original.NewObjectsClient(tenantID) } diff --git a/profiles/preview/graphrbac/graphrbac/models.go b/profiles/preview/graphrbac/graphrbac/models.go index 71479bb86fc3..a7236df2fce4 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 @@ -84,6 +85,7 @@ type PasswordCredential = original.PasswordCredential type PasswordCredentialListResult = original.PasswordCredentialListResult type PasswordCredentialsUpdateParameters = original.PasswordCredentialsUpdateParameters type PasswordProfile = original.PasswordProfile +type Permissions = original.Permissions type RequiredResourceAccess = original.RequiredResourceAccess type ResourceAccess = original.ResourceAccess type ServicePrincipal = original.ServicePrincipal @@ -101,6 +103,7 @@ type UserListResult = original.UserListResult type UserListResultIterator = original.UserListResultIterator type UserListResultPage = original.UserListResultPage type UserUpdateParameters = original.UserUpdateParameters +type OAuth2Client = original.OAuth2Client type ObjectsClient = original.ObjectsClient type ServicePrincipalsClient = original.ServicePrincipalsClient type UsersClient = original.UsersClient @@ -117,6 +120,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) } @@ -135,6 +144,12 @@ func PossibleObjectTypeValues() []ObjectType { func PossibleUserTypeValues() []UserType { return original.PossibleUserTypeValues() } +func NewOAuth2Client(tenantID string) OAuth2Client { + return original.NewOAuth2Client(tenantID) +} +func NewOAuth2ClientWithBaseURI(baseURI string, tenantID string) OAuth2Client { + return original.NewOAuth2ClientWithBaseURI(baseURI, tenantID) +} func NewObjectsClient(tenantID string) ObjectsClient { return original.NewObjectsClient(tenantID) } diff --git a/services/graphrbac/1.6/graphrbac/applications.go b/services/graphrbac/1.6/graphrbac/applications.go index 61c0c5313ee9..b7dedd44efe9 100644 --- a/services/graphrbac/1.6/graphrbac/applications.go +++ b/services/graphrbac/1.6/graphrbac/applications.go @@ -318,6 +318,70 @@ func (client ApplicationsClient) GetResponder(resp *http.Response) (result Appli return } +// HardDelete hard-delete an application. +// Parameters: +// applicationObjectID - application object ID. +func (client ApplicationsClient) 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.ApplicationsClient", "HardDelete", nil, "Failure preparing request") + return + } + + resp, err := client.HardDeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "HardDelete", resp, "Failure sending request") + return + } + + result, err = client.HardDeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "HardDelete", resp, "Failure responding to request") + } + + return +} + +// HardDeletePreparer prepares the HardDelete request. +func (client ApplicationsClient) 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 ApplicationsClient) 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 ApplicationsClient) 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 lists applications by filter parameters. // Parameters: // filter - the filters to apply to the operation. diff --git a/services/graphrbac/1.6/graphrbac/deletedapplications.go b/services/graphrbac/1.6/graphrbac/deletedapplications.go new file mode 100644 index 000000000000..486c5906881a --- /dev/null +++ b/services/graphrbac/1.6/graphrbac/deletedapplications.go @@ -0,0 +1,155 @@ +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" + "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)} +} + +// Get gets a list of deleted applications in the directory. +func (client DeletedApplicationsClient) Get(ctx context.Context) (result ApplicationListResult, err error) { + req, err := client.GetPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "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.DeletedApplicationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.DeletedApplicationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DeletedApplicationsClient) GetPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "tenantID": autorest.Encode("path", client.TenantID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/deletedApplications", pathParameters)) + 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 DeletedApplicationsClient) 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 DeletedApplicationsClient) GetResponder(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), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/deletedApplications/{objectId}/restore", pathParameters)) + 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/models.go b/services/graphrbac/1.6/graphrbac/models.go index 1db6301a64e6..e7057e1b7b38 100644 --- a/services/graphrbac/1.6/graphrbac/models.go +++ b/services/graphrbac/1.6/graphrbac/models.go @@ -1338,6 +1338,27 @@ func (pp PasswordProfile) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// Permissions ... +type Permissions struct { + autorest.Response `json:"-"` + // OdataType - Microsoft.DirectoryServices.OAuth2PermissionGrant + OdataType *string `json:"odata.type,omitempty"` + // ClientID - The objectId of the Service Principal associated with the app + ClientID *string `json:"clientId,omitempty"` + // ConsentType - Typically set to AllPrincipals + ConsentType *string `json:"consentType,omitempty"` + // PrincipalID - Set to null if AllPrincipals is set + PrincipalID interface{} `json:"principalId,omitempty"` + // ResourceID - Service Principal Id of the resource you want to grant + ResourceID *string `json:"resourceId,omitempty"` + // Scope - Typically set to user_impersonation + Scope *string `json:"scope,omitempty"` + // StartTime - Start time for TTL + StartTime *string `json:"startTime,omitempty"` + // ExpiryTime - Expiry time for TTL + ExpiryTime *string `json:"expiryTime,omitempty"` +} + // RequiredResourceAccess specifies the set of OAuth 2.0 permission scopes and app roles under the specified // resource that an application requires access to. The specified OAuth 2.0 permission scopes may be requested by // client applications (through the requiredResourceAccess collection) when calling a resource application. The diff --git a/services/graphrbac/1.6/graphrbac/oauth2.go b/services/graphrbac/1.6/graphrbac/oauth2.go new file mode 100644 index 000000000000..97d465bf13b2 --- /dev/null +++ b/services/graphrbac/1.6/graphrbac/oauth2.go @@ -0,0 +1,176 @@ +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" + "net/http" +) + +// OAuth2Client is the the Graph RBAC Management Client +type OAuth2Client struct { + BaseClient +} + +// NewOAuth2Client creates an instance of the OAuth2Client client. +func NewOAuth2Client(tenantID string) OAuth2Client { + return NewOAuth2ClientWithBaseURI(DefaultBaseURI, tenantID) +} + +// NewOAuth2ClientWithBaseURI creates an instance of the OAuth2Client client. +func NewOAuth2ClientWithBaseURI(baseURI string, tenantID string) OAuth2Client { + return OAuth2Client{NewWithBaseURI(baseURI, tenantID)} +} + +// Get queries OAuth2 permissions for the relevant SP ObjectId of an app. +// Parameters: +// filter - this is the Service Principal ObjectId associated with the app +func (client OAuth2Client) Get(ctx context.Context, filter string) (result Permissions, err error) { + req, err := client.GetPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "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.OAuth2Client", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client OAuth2Client) GetPreparer(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}/oauth2PermissionGrants", 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 OAuth2Client) 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 OAuth2Client) GetResponder(resp *http.Response) (result Permissions, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Post 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) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Post", nil, "Failure preparing request") + return + } + + resp, err := client.PostSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Post", resp, "Failure sending request") + return + } + + result, err = client.PostResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.OAuth2Client", "Post", resp, "Failure responding to request") + } + + return +} + +// PostPreparer prepares the Post request. +func (client OAuth2Client) PostPreparer(ctx context.Context, body *Permissions) (*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.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/oauth2PermissionGrants", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostSender sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (client OAuth2Client) PostSender(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 +// closes the http.Response Body. +func (client OAuth2Client) PostResponder(resp *http.Response) (result Permissions, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/graphrbac/1.6/graphrbac/serviceprincipals.go b/services/graphrbac/1.6/graphrbac/serviceprincipals.go index 4caf3f817e1f..2b09eaf96dc7 100644 --- a/services/graphrbac/1.6/graphrbac/serviceprincipals.go +++ b/services/graphrbac/1.6/graphrbac/serviceprincipals.go @@ -178,7 +178,7 @@ func (client ServicePrincipalsClient) DeleteResponder(resp *http.Response) (resu return } -// Get gets service principal information from the directory. +// Get gets service principal information from the directory. Query by objectId or pass a filter to query by appId // Parameters: // objectID - the object ID of the service principal to get. func (client ServicePrincipalsClient) Get(ctx context.Context, objectID string) (result ServicePrincipal, err error) {