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

azuread_user: additional fields for resource and data source #351

Merged
merged 1 commit into from
Nov 19, 2020
Merged
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
116 changes: 116 additions & 0 deletions internal/services/aadgraph/user_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ func userData() *schema.Resource {
Computed: true,
},

"given_name": {
Type: schema.TypeString,
Computed: true,
Description: "The given name (first name) of the user.",
},

"surname": {
Type: schema.TypeString,
Computed: true,
Description: "The user's surname (family name or last name).",
},

"immutable_id": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -78,6 +90,68 @@ func userData() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"job_title": {
Type: schema.TypeString,
Computed: true,
Description: "The user’s job title.",
},

"department": {
Type: schema.TypeString,
Computed: true,
Description: "The name for the department in which the user works.",
},

"company_name": {
Type: schema.TypeString,
Computed: true,
Description: "The company name which the user is associated. " +
"This property can be useful for describing the company that an external user comes from.",
},

"physical_delivery_office_name": {
Type: schema.TypeString,
Computed: true,
Description: "The office location in the user's place of business.",
},

"street_address": {
Type: schema.TypeString,
Computed: true,
Description: "The street address of the user's place of business.",
},

"city": {
Type: schema.TypeString,
Computed: true,
Description: "The city/region in which the user is located; for example, “US” or “UK”.",
},

"state": {
Type: schema.TypeString,
Computed: true,
Description: "The state or province in the user's address.",
},

"country": {
Type: schema.TypeString,
Computed: true,
Description: "The country/region in which the user is located; for example, “US” or “UK”.",
},

"postal_code": {
Type: schema.TypeString,
Computed: true,
Description: "The postal code for the user's postal address. The postal code is specific to the user's country/region. " +
"In the United States of America, this attribute contains the ZIP code.",
},

"mobile": {
Type: schema.TypeString,
Computed: true,
Description: "The primary cellular telephone number for the user.",
},
},
}
}
Expand Down Expand Up @@ -128,11 +202,53 @@ func userDataRead(d *schema.ResourceData, meta interface{}) error {
d.Set("user_principal_name", user.UserPrincipalName)
d.Set("account_enabled", user.AccountEnabled)
d.Set("display_name", user.DisplayName)
d.Set("given_name", user.GivenName)
d.Set("surname", user.Surname)
d.Set("immutable_id", user.ImmutableID)
d.Set("mail", user.Mail)
d.Set("mail_nickname", user.MailNickname)
d.Set("usage_location", user.UsageLocation)

if v, ok := user.AdditionalProperties["jobTitle"]; ok {
d.Set("job_title", v.(string))
}

if v, ok := user.AdditionalProperties["department"]; ok {
d.Set("department", v.(string))
}

if v, ok := user.AdditionalProperties["companyName"]; ok {
d.Set("company_name", v.(string))
}

if v, ok := user.AdditionalProperties["physicalDeliveryOfficeName"]; ok {
d.Set("physical_delivery_office_name", v.(string))
}

if v, ok := user.AdditionalProperties["streetAddress"]; ok {
d.Set("street_address", v.(string))
}

if v, ok := user.AdditionalProperties["city"]; ok {
d.Set("city", v.(string))
}

if v, ok := user.AdditionalProperties["state"]; ok {
d.Set("state", v.(string))
}

if v, ok := user.AdditionalProperties["country"]; ok {
d.Set("country", v.(string))
}

if v, ok := user.AdditionalProperties["postalCode"]; ok {
d.Set("postal_code", v.(string))
}

if v, ok := user.AdditionalProperties["mobile"]; ok {
d.Set("mobile", v.(string))
}

d.Set("onpremises_sam_account_name", user.AdditionalProperties["onPremisesSamAccountName"])
d.Set("onpremises_user_principal_name", user.AdditionalProperties["onPremisesUserPrincipalName"])

Expand Down
Loading