Skip to content

Commit

Permalink
Merge pull request #896 from hashicorp/feature/serviceprincipals-v1.0…
Browse files Browse the repository at this point in the history
…-api

Service Principals: Use v1.0 API
  • Loading branch information
manicminer authored Sep 29, 2022
2 parents 71bd955 + a9efb47 commit 716e4c9
Show file tree
Hide file tree
Showing 17 changed files with 456 additions and 30 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0
github.com/manicminer/hamilton v0.47.1
github.com/manicminer/hamilton v0.49.0
golang.org/x/text v0.3.7
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/manicminer/hamilton v0.47.1 h1:nMH4oOa2lPAfCeLGEB1o+XzhyJUHPRimlWz/hB2WC5E=
github.com/manicminer/hamilton v0.47.1/go.mod h1:lbVyngC+/nCWuDp8UhC6Bw+bh7jcP/E+YwqzHTmzemk=
github.com/manicminer/hamilton v0.49.0 h1:n4GDhEZgpsKANu7G1Q1CI2FVLiQTNJQ684U6NX94AVk=
github.com/manicminer/hamilton v0.49.0/go.mod h1:lbVyngC+/nCWuDp8UhC6Bw+bh7jcP/E+YwqzHTmzemk=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
Expand Down
6 changes: 3 additions & 3 deletions internal/services/groups/group_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func groupDataSourceRead(ctx context.Context, d *schema.ResourceData, meta inter
d.SetId(*group.ID)

tf.Set(d, "assignable_to_role", group.IsAssignableToRole)
tf.Set(d, "behaviors", tf.FlattenStringSlice(group.ResourceBehaviorOptions))
tf.Set(d, "behaviors", tf.FlattenStringSlicePtr(group.ResourceBehaviorOptions))
tf.Set(d, "description", group.Description)
tf.Set(d, "display_name", group.DisplayName)
tf.Set(d, "mail", group.Mail)
Expand All @@ -328,7 +328,7 @@ func groupDataSourceRead(ctx context.Context, d *schema.ResourceData, meta inter
tf.Set(d, "onpremises_security_identifier", group.OnPremisesSecurityIdentifier)
tf.Set(d, "onpremises_sync_enabled", group.OnPremisesSyncEnabled)
tf.Set(d, "preferred_language", group.PreferredLanguage)
tf.Set(d, "provisioning_options", tf.FlattenStringSlice(group.ResourceProvisioningOptions))
tf.Set(d, "provisioning_options", tf.FlattenStringSlicePtr(group.ResourceProvisioningOptions))
tf.Set(d, "proxy_addresses", tf.FlattenStringSlicePtr(group.ProxyAddresses))
tf.Set(d, "security_enabled", group.SecurityEnabled)
tf.Set(d, "theme", group.Theme)
Expand All @@ -349,7 +349,7 @@ func groupDataSourceRead(ctx context.Context, d *schema.ResourceData, meta inter
tf.Set(d, "dynamic_membership", dynamicMembership)

var allowExternalSenders, autoSubscribeNewMembers, hideFromAddressLists, hideFromOutlookClients bool
if hasGroupType(group.GroupTypes, msgraph.GroupTypeUnified) {
if group.GroupTypes != nil && hasGroupType(*group.GroupTypes, msgraph.GroupTypeUnified) {
groupExtra, err := groupGetAdditional(ctx, client, d.Id())
if err != nil {
return tf.ErrorDiagF(err, "Could not retrieve group with object ID %q", d.Id())
Expand Down
12 changes: 6 additions & 6 deletions internal/services/groups/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter
properties := msgraph.Group{
Description: utils.NullableString(description),
DisplayName: utils.String(tempDisplayName),
GroupTypes: groupTypes,
GroupTypes: &groupTypes,
IsAssignableToRole: utils.Bool(d.Get("assignable_to_role").(bool)),
MailEnabled: utils.Bool(mailEnabled),
MailNickname: utils.String(mailNickname),
MembershipRule: utils.NullableString(""),
ResourceBehaviorOptions: behaviorOptions,
ResourceProvisioningOptions: provisioningOptions,
ResourceBehaviorOptions: &behaviorOptions,
ResourceProvisioningOptions: &provisioningOptions,
SecurityEnabled: utils.Bool(securityEnabled),
}

Expand Down Expand Up @@ -1083,7 +1083,7 @@ func groupResourceRead(ctx context.Context, d *schema.ResourceData, meta interfa
}

tf.Set(d, "assignable_to_role", group.IsAssignableToRole)
tf.Set(d, "behaviors", tf.FlattenStringSlice(group.ResourceBehaviorOptions))
tf.Set(d, "behaviors", tf.FlattenStringSlicePtr(group.ResourceBehaviorOptions))
tf.Set(d, "description", group.Description)
tf.Set(d, "display_name", group.DisplayName)
tf.Set(d, "mail_enabled", group.MailEnabled)
Expand All @@ -1096,7 +1096,7 @@ func groupResourceRead(ctx context.Context, d *schema.ResourceData, meta interfa
tf.Set(d, "onpremises_security_identifier", group.OnPremisesSecurityIdentifier)
tf.Set(d, "onpremises_sync_enabled", group.OnPremisesSyncEnabled)
tf.Set(d, "preferred_language", group.PreferredLanguage)
tf.Set(d, "provisioning_options", tf.FlattenStringSlice(group.ResourceProvisioningOptions))
tf.Set(d, "provisioning_options", tf.FlattenStringSlicePtr(group.ResourceProvisioningOptions))
tf.Set(d, "proxy_addresses", tf.FlattenStringSlicePtr(group.ProxyAddresses))
tf.Set(d, "security_enabled", group.SecurityEnabled)
tf.Set(d, "theme", group.Theme)
Expand All @@ -1117,7 +1117,7 @@ func groupResourceRead(ctx context.Context, d *schema.ResourceData, meta interfa
tf.Set(d, "dynamic_membership", dynamicMembership)

var allowExternalSenders, autoSubscribeNewMembers, hideFromAddressLists, hideFromOutlookClients bool
if hasGroupType(group.GroupTypes, msgraph.GroupTypeUnified) {
if group.GroupTypes != nil && hasGroupType(*group.GroupTypes, msgraph.GroupTypeUnified) {
groupExtra, err := groupGetAdditional(ctx, client, d.Id())
if err != nil {
return tf.ErrorDiagF(err, "Could not retrieve group with object UID %q", d.Id())
Expand Down
1 change: 1 addition & 0 deletions internal/services/serviceprincipals/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func NewClient(o *common.ClientOptions) *Client {
o.ConfigureClient(&directoryObjectsClient.BaseClient)

servicePrincipalsClient := msgraph.NewServicePrincipalsClient(o.TenantID)
servicePrincipalsClient.BaseClient.ApiVersion = msgraph.Version10
o.ConfigureClient(&servicePrincipalsClient.BaseClient)

return &Client{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ func servicePrincipalDataSourceRead(ctx context.Context, d *schema.ResourceData,
tf.Set(d, "login_url", servicePrincipal.LoginUrl)
tf.Set(d, "notes", servicePrincipal.Notes)
tf.Set(d, "notification_email_addresses", tf.FlattenStringSlicePtr(servicePrincipal.NotificationEmailAddresses))
tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.PublishedPermissionScopes))
tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.PublishedPermissionScopes))
tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.OAuth2PermissionScopes))
tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.OAuth2PermissionScopes))
tf.Set(d, "object_id", servicePrincipal.ID)
tf.Set(d, "preferred_single_sign_on_mode", servicePrincipal.PreferredSingleSignOnMode)
tf.Set(d, "redirect_uris", tf.FlattenStringSlicePtr(servicePrincipal.ReplyUrls))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ func servicePrincipalResourceRead(ctx context.Context, d *schema.ResourceData, m
tf.Set(d, "login_url", servicePrincipal.LoginUrl)
tf.Set(d, "notes", servicePrincipal.Notes)
tf.Set(d, "notification_email_addresses", tf.FlattenStringSlicePtr(servicePrincipal.NotificationEmailAddresses))
tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.PublishedPermissionScopes))
tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.PublishedPermissionScopes))
tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.OAuth2PermissionScopes))
tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.OAuth2PermissionScopes))
tf.Set(d, "object_id", servicePrincipal.ID)
tf.Set(d, "preferred_single_sign_on_mode", servicePrincipal.PreferredSingleSignOnMode)
tf.Set(d, "redirect_uris", tf.FlattenStringSlicePtr(servicePrincipal.ReplyUrls))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 171 additions & 0 deletions vendor/github.com/manicminer/hamilton/msgraph/b2c_userflow.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 49 additions & 4 deletions vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 716e4c9

Please sign in to comment.