From 54ebd934377ee5b33093f2b160d8841d200c2aed Mon Sep 17 00:00:00 2001 From: Spyros Synodinos Date: Fri, 8 Dec 2023 16:28:28 +0200 Subject: [PATCH] fixes ApplicationsById to ByApplicationId --- go.mod | 2 +- go.sum | 4 ++-- pkg/idp/provider/azure/azure.go | 16 +++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 849902f..de78f51 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/google/uuid v1.4.0 github.com/microsoft/kiota-abstractions-go v0.20.0 github.com/microsoft/kiota-authentication-azure-go v0.6.0 - github.com/microsoftgraph/msgraph-sdk-go v0.57.0 + github.com/microsoftgraph/msgraph-sdk-go v0.64.0 github.com/onsi/ginkgo/v2 v2.13.2 github.com/onsi/gomega v1.30.0 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 diff --git a/go.sum b/go.sum index bce3e59..9a3d86b 100644 --- a/go.sum +++ b/go.sum @@ -1086,8 +1086,8 @@ github.com/microsoft/kiota-serialization-json-go v0.9.2 h1:L2lrFY5um4P1JI99cmWSn github.com/microsoft/kiota-serialization-json-go v0.9.2/go.mod h1:6hPKJ/QvuYsDHo17i0hYItDRPN+Bswz2AJfD7sCj+Z0= github.com/microsoft/kiota-serialization-text-go v0.7.1 h1:PSBVPLboxFb03ye9jn4Q1tn18EyKFXEB9UvyVWIs/qM= github.com/microsoft/kiota-serialization-text-go v0.7.1/go.mod h1:BPzhQYFd2xVJffDrOH4rkHzlt+CQyeX55L913fvKvUY= -github.com/microsoftgraph/msgraph-sdk-go v0.57.0 h1:tlSJjkilLg6JZFOzr8xuEJxdRus6YGrU3mfuRds/G8Y= -github.com/microsoftgraph/msgraph-sdk-go v0.57.0/go.mod h1:Mx6MtE72N62+RGcQE4vHCPDvVCb5q5BclBLY9hxPcJs= +github.com/microsoftgraph/msgraph-sdk-go v0.64.0 h1:ICwg25aAHR7aER230nhtBPdp8ju21Lqh7zZMj7lmxRA= +github.com/microsoftgraph/msgraph-sdk-go v0.64.0/go.mod h1:I6VgbQi+guNjjCWKSoh0WaVQf2cpgmMqsUWSNBmhm6U= github.com/microsoftgraph/msgraph-sdk-go-core v0.36.1 h1:TsEECo911Z/0dB/xxEB852/BX14LnU/GvTyJTuysx48= github.com/microsoftgraph/msgraph-sdk-go-core v0.36.1/go.mod h1:6fRetxmlg2LyRDf/wX8h7JP3cj+2JVhI50RqYJk4CIY= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= diff --git a/pkg/idp/provider/azure/azure.go b/pkg/idp/provider/azure/azure.go index 55cf323..658ddbd 100644 --- a/pkg/idp/provider/azure/azure.go +++ b/pkg/idp/provider/azure/azure.go @@ -199,7 +199,9 @@ func (a *Azure) createOrUpdateApplication(config provider.AppConfig, ctx context //Update if needed if needsUpdate, patch := a.computeAppUpdatePatch(config, app, parentApp); needsUpdate { - _, err = a.Client.ApplicationsById(*id).Patch(ctx, patch, nil) + applicationsClient := a.Client.Applications() + applicationObjectID := *id + _, err := applicationsClient.ByApplicationId(applicationObjectID).Patch(ctx, patch, nil) if err != nil { return "", microerror.Maskf(requestFailedError, PrintOdataError(err)) } @@ -210,7 +212,8 @@ func (a *Azure) createOrUpdateApplication(config provider.AppConfig, ctx context func (a *Azure) CreateOrUpdateSecret(id string, config provider.AppConfig, ctx context.Context, oldSecret string, skipDelete bool) (provider.ProviderSecret, error) { - app, err := a.Client.ApplicationsById(id).Get(ctx, nil) + applicationsClient := a.Client.Applications() + app, err := applicationsClient.ByApplicationId(id).Get(ctx, nil) if err != nil { return provider.ProviderSecret{}, microerror.Maskf(requestFailedError, PrintOdataError(err)) } @@ -244,7 +247,8 @@ func (a *Azure) CreateOrUpdateSecret(id string, config provider.AppConfig, ctx c // Create secret if it does not exist if needsCreation { - secret, err = a.Client.ApplicationsById(id).AddPassword().Post(ctx, GetSecretCreateRequestBody(config), nil) + passwordRequestBody := applications.NewItemAddPasswordPostRequestBody() + secret, err := applicationsClient.ByApplicationId(id).AddPassword().Post(ctx, passwordRequestBody, nil) if err != nil { return provider.ProviderSecret{}, microerror.Maskf(requestFailedError, PrintOdataError(err)) } @@ -254,10 +258,11 @@ func (a *Azure) CreateOrUpdateSecret(id string, config provider.AppConfig, ctx c } func (a *Azure) DeleteSecret(ctx context.Context, secretID *uuid.UUID, appID string) error { + applicationsClient := a.Client.Applications() requestBody := applications.NewItemRemovePasswordPostRequestBody() requestBody.SetKeyId(secretID) - err := a.Client.ApplicationsById(appID).RemovePassword().Post(ctx, requestBody, nil) + err := applicationsClient.ByApplicationId(appID).RemovePassword().Post(ctx, requestBody, nil) if err != nil { return microerror.Maskf(requestFailedError, PrintOdataError(err)) } @@ -272,7 +277,8 @@ func (a *Azure) DeleteApp(name string, ctx context.Context) error { } return microerror.Mask(err) } - if err := a.Client.ApplicationsById(appID).Delete(ctx, nil); err != nil { + applicationsClient := a.Client.Applications() + if err := applicationsClient.ByApplicationId(appID).Delete(ctx, nil); err != nil { return microerror.Maskf(requestFailedError, PrintOdataError(err)) } a.Log.Info(fmt.Sprintf("Deleted %s app %s for %s in microsoft ad tenant %s", a.Type, name, a.Owner, a.TenantID))