Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes ApplicationsById to ByApplicationId #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
16 changes: 11 additions & 5 deletions pkg/idp/provider/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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))
}
Expand Down Expand Up @@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work/get the same result as GetSecretCreateRequestBody(config)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really sure, this is what I understood from what I saw in the library

secret, err := applicationsClient.ByApplicationId(id).AddPassword().Post(ctx, passwordRequestBody, nil)
if err != nil {
return provider.ProviderSecret{}, microerror.Maskf(requestFailedError, PrintOdataError(err))
}
Expand All @@ -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))
}
Expand All @@ -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))
Expand Down