|
| 1 | +package gsuite |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform/helper/schema" |
| 7 | +) |
| 8 | + |
| 9 | +func dataGroupSettings() *schema.Resource { |
| 10 | + return &schema.Resource{ |
| 11 | + Read: dataGroupSettingsRead, |
| 12 | + Schema: map[string]*schema.Schema{ |
| 13 | + "email": { |
| 14 | + Type: schema.TypeString, |
| 15 | + Required: true, |
| 16 | + }, |
| 17 | + |
| 18 | + "is_archived": { |
| 19 | + Type: schema.TypeString, |
| 20 | + Computed: true, |
| 21 | + }, |
| 22 | + "kind": { |
| 23 | + Type: schema.TypeString, |
| 24 | + Computed: true, |
| 25 | + }, |
| 26 | + "name": { |
| 27 | + Type: schema.TypeString, |
| 28 | + Computed: true, |
| 29 | + }, |
| 30 | + "description": { |
| 31 | + Type: schema.TypeString, |
| 32 | + Computed: true, |
| 33 | + }, |
| 34 | + "allow_external_members": { |
| 35 | + Type: schema.TypeString, |
| 36 | + Computed: true, |
| 37 | + }, |
| 38 | + "allow_google_communication": { |
| 39 | + Type: schema.TypeString, |
| 40 | + Computed: true, |
| 41 | + }, |
| 42 | + "allow_web_posting": { |
| 43 | + Type: schema.TypeString, |
| 44 | + Computed: true, |
| 45 | + }, |
| 46 | + "archive_only": { |
| 47 | + Type: schema.TypeString, |
| 48 | + Computed: true, |
| 49 | + }, |
| 50 | + "custom_footer_text": { |
| 51 | + Type: schema.TypeString, |
| 52 | + Computed: true, |
| 53 | + }, |
| 54 | + "custom_reply_to": { |
| 55 | + Type: schema.TypeString, |
| 56 | + Computed: true, |
| 57 | + }, |
| 58 | + "favorite_replies_on_top": { |
| 59 | + Type: schema.TypeString, |
| 60 | + Computed: true, |
| 61 | + }, |
| 62 | + "include_custom_footer": { |
| 63 | + Type: schema.TypeString, |
| 64 | + Computed: true, |
| 65 | + }, |
| 66 | + "include_in_global_address_list": { |
| 67 | + Type: schema.TypeString, |
| 68 | + Computed: true, |
| 69 | + }, |
| 70 | + "max_message_bytes": { |
| 71 | + Type: schema.TypeInt, |
| 72 | + Computed: true, |
| 73 | + }, |
| 74 | + "members_can_post_as_the_group": { |
| 75 | + Type: schema.TypeString, |
| 76 | + Computed: true, |
| 77 | + }, |
| 78 | + "message_display_font": { |
| 79 | + Type: schema.TypeString, |
| 80 | + Computed: true, |
| 81 | + }, |
| 82 | + "message_moderation_level": { |
| 83 | + Type: schema.TypeString, |
| 84 | + Computed: true, |
| 85 | + }, |
| 86 | + "primary_language": { |
| 87 | + Type: schema.TypeString, |
| 88 | + Computed: true, |
| 89 | + }, |
| 90 | + "reply_to": { |
| 91 | + Type: schema.TypeString, |
| 92 | + Computed: true, |
| 93 | + }, |
| 94 | + "send_message_deny_notification": { |
| 95 | + Type: schema.TypeString, |
| 96 | + Computed: true, |
| 97 | + }, |
| 98 | + "show_in_group_directory": { |
| 99 | + Type: schema.TypeString, |
| 100 | + Computed: true, |
| 101 | + }, |
| 102 | + "spam_moderation_level": { |
| 103 | + Type: schema.TypeString, |
| 104 | + Computed: true, |
| 105 | + }, |
| 106 | + "who_can_add": { |
| 107 | + Type: schema.TypeString, |
| 108 | + Computed: true, |
| 109 | + }, |
| 110 | + "who_can_add_references": { |
| 111 | + Type: schema.TypeString, |
| 112 | + Computed: true, |
| 113 | + }, |
| 114 | + "who_can_approve_members": { |
| 115 | + Type: schema.TypeString, |
| 116 | + Computed: true, |
| 117 | + }, |
| 118 | + "who_can_approve_messages": { |
| 119 | + Type: schema.TypeString, |
| 120 | + Computed: true, |
| 121 | + }, |
| 122 | + "who_can_assign_topics": { |
| 123 | + Type: schema.TypeString, |
| 124 | + Computed: true, |
| 125 | + }, |
| 126 | + "who_can_assist_content": { |
| 127 | + Type: schema.TypeString, |
| 128 | + Computed: true, |
| 129 | + }, |
| 130 | + "who_can_ban_users": { |
| 131 | + Type: schema.TypeString, |
| 132 | + Computed: true, |
| 133 | + }, |
| 134 | + "who_can_contact_owner": { |
| 135 | + Type: schema.TypeString, |
| 136 | + Computed: true, |
| 137 | + }, |
| 138 | + "who_can_delete_any_post": { |
| 139 | + Type: schema.TypeString, |
| 140 | + Computed: true, |
| 141 | + }, |
| 142 | + "who_can_delete_topics": { |
| 143 | + Type: schema.TypeString, |
| 144 | + Computed: true, |
| 145 | + }, |
| 146 | + "who_can_discover_group": { |
| 147 | + Type: schema.TypeString, |
| 148 | + Computed: true, |
| 149 | + }, |
| 150 | + "who_can_enter_free_form_tags": { |
| 151 | + Type: schema.TypeString, |
| 152 | + Computed: true, |
| 153 | + }, |
| 154 | + "who_can_hide_abuse": { |
| 155 | + Type: schema.TypeString, |
| 156 | + Computed: true, |
| 157 | + }, |
| 158 | + "who_can_invite": { |
| 159 | + Type: schema.TypeString, |
| 160 | + Computed: true, |
| 161 | + }, |
| 162 | + "who_can_join": { |
| 163 | + Type: schema.TypeString, |
| 164 | + Computed: true, |
| 165 | + }, |
| 166 | + "who_can_leave_group": { |
| 167 | + Type: schema.TypeString, |
| 168 | + Computed: true, |
| 169 | + }, |
| 170 | + "who_can_lock_topics": { |
| 171 | + Type: schema.TypeString, |
| 172 | + Computed: true, |
| 173 | + }, |
| 174 | + "who_can_make_topics_sticky": { |
| 175 | + Type: schema.TypeString, |
| 176 | + Computed: true, |
| 177 | + }, |
| 178 | + "who_can_mark_duplicate": { |
| 179 | + Type: schema.TypeString, |
| 180 | + Computed: true, |
| 181 | + }, |
| 182 | + "who_can_mark_favorite_reply_on_any_topic": { |
| 183 | + Type: schema.TypeString, |
| 184 | + Computed: true, |
| 185 | + }, |
| 186 | + "who_can_mark_favorite_reply_on_own_topic": { |
| 187 | + Type: schema.TypeString, |
| 188 | + Computed: true, |
| 189 | + }, |
| 190 | + "who_can_mark_no_response_needed": { |
| 191 | + Type: schema.TypeString, |
| 192 | + Computed: true, |
| 193 | + }, |
| 194 | + "who_can_moderate_content": { |
| 195 | + Type: schema.TypeString, |
| 196 | + Computed: true, |
| 197 | + }, |
| 198 | + "who_can_moderate_members": { |
| 199 | + Type: schema.TypeString, |
| 200 | + Computed: true, |
| 201 | + }, |
| 202 | + "who_can_modify_members": { |
| 203 | + Type: schema.TypeString, |
| 204 | + Computed: true, |
| 205 | + }, |
| 206 | + "who_can_modify_tags_and_categories": { |
| 207 | + Type: schema.TypeString, |
| 208 | + Computed: true, |
| 209 | + }, |
| 210 | + "who_can_move_topics_in": { |
| 211 | + Type: schema.TypeString, |
| 212 | + Computed: true, |
| 213 | + }, |
| 214 | + "who_can_move_topics_out": { |
| 215 | + Type: schema.TypeString, |
| 216 | + Computed: true, |
| 217 | + }, |
| 218 | + "who_can_post_announcements": { |
| 219 | + Type: schema.TypeString, |
| 220 | + Computed: true, |
| 221 | + }, |
| 222 | + "who_can_post_message": { |
| 223 | + Type: schema.TypeString, |
| 224 | + Computed: true, |
| 225 | + }, |
| 226 | + "who_can_take_topics": { |
| 227 | + Type: schema.TypeString, |
| 228 | + Computed: true, |
| 229 | + }, |
| 230 | + "who_can_unassign_topic": { |
| 231 | + Type: schema.TypeString, |
| 232 | + Computed: true, |
| 233 | + }, |
| 234 | + "who_can_unmark_favorite_reply_on_any_topic": { |
| 235 | + Type: schema.TypeString, |
| 236 | + Computed: true, |
| 237 | + }, |
| 238 | + "who_can_view_group": { |
| 239 | + Type: schema.TypeString, |
| 240 | + Computed: true, |
| 241 | + }, |
| 242 | + "who_can_view_membership": { |
| 243 | + Type: schema.TypeString, |
| 244 | + Computed: true, |
| 245 | + }, |
| 246 | + }, |
| 247 | + } |
| 248 | +} |
| 249 | + |
| 250 | +func dataGroupSettingsRead(d *schema.ResourceData, meta interface{}) error { |
| 251 | + config := meta.(*Config) |
| 252 | + |
| 253 | + id, err := config.groupSettings.Groups.Get(d.Get("email").(string)).Do() |
| 254 | + if err != nil { |
| 255 | + return fmt.Errorf("[ERROR] Error fetching group settings. Make sure the group exists: %s ", err) |
| 256 | + } |
| 257 | + |
| 258 | + d.SetId(d.Get("email").(string)) |
| 259 | + d.Set("allow_external_members", id.AllowExternalMembers) |
| 260 | + d.Set("allow_google_communication", id.AllowGoogleCommunication) |
| 261 | + d.Set("allow_web_posting", id.AllowWebPosting) |
| 262 | + d.Set("archive_only", id.ArchiveOnly) |
| 263 | + d.Set("custom_footer_text", id.CustomFooterText) |
| 264 | + d.Set("custom_reply_to", id.CustomReplyTo) |
| 265 | + d.Set("description", id.Description) |
| 266 | + d.Set("favorite_replies_on_top", id.FavoriteRepliesOnTop) |
| 267 | + d.Set("include_custom_footer", id.IncludeCustomFooter) |
| 268 | + d.Set("include_in_global_address_list", id.IncludeInGlobalAddressList) |
| 269 | + d.Set("max_message_bytes", id.MaxMessageBytes) |
| 270 | + d.Set("members_can_post_as_the_group", id.MembersCanPostAsTheGroup) |
| 271 | + d.Set("message_display_font", id.MessageDisplayFont) |
| 272 | + d.Set("message_moderation_level", id.MessageModerationLevel) |
| 273 | + d.Set("primary_language", id.PrimaryLanguage) |
| 274 | + d.Set("reply_to", id.ReplyTo) |
| 275 | + d.Set("send_message_deny_notification", id.SendMessageDenyNotification) |
| 276 | + d.Set("show_in_group_directory", id.ShowInGroupDirectory) |
| 277 | + d.Set("spam_moderation_level", id.SpamModerationLevel) |
| 278 | + d.Set("who_can_add", id.WhoCanAdd) |
| 279 | + d.Set("who_can_add_references", id.WhoCanAddReferences) |
| 280 | + d.Set("who_can_approve_members", id.WhoCanApproveMembers) |
| 281 | + d.Set("who_can_approve_messages", id.WhoCanApproveMessages) |
| 282 | + d.Set("who_can_assign_topics", id.WhoCanAssignTopics) |
| 283 | + d.Set("who_can_assist_content", id.WhoCanAssistContent) |
| 284 | + d.Set("who_can_ban_users", id.WhoCanBanUsers) |
| 285 | + d.Set("who_can_contact_owner", id.WhoCanContactOwner) |
| 286 | + d.Set("who_can_delete_any_post", id.WhoCanDeleteAnyPost) |
| 287 | + d.Set("who_can_delete_topics", id.WhoCanDeleteTopics) |
| 288 | + d.Set("who_can_discover_group", id.WhoCanDiscoverGroup) |
| 289 | + d.Set("who_can_enter_free_form_tags", id.WhoCanEnterFreeFormTags) |
| 290 | + d.Set("who_can_hide_abuse", id.WhoCanHideAbuse) |
| 291 | + d.Set("who_can_invite", id.WhoCanInvite) |
| 292 | + d.Set("who_can_join", id.WhoCanJoin) |
| 293 | + d.Set("who_can_leave_group", id.WhoCanLeaveGroup) |
| 294 | + d.Set("who_can_lock_topics", id.WhoCanLockTopics) |
| 295 | + d.Set("who_can_make_topics_sticky", id.WhoCanMakeTopicsSticky) |
| 296 | + d.Set("who_can_mark_duplicate", id.WhoCanMarkDuplicate) |
| 297 | + d.Set("who_can_mark_favorite_reply_on_any_topic", id.WhoCanMarkFavoriteReplyOnAnyTopic) |
| 298 | + d.Set("who_can_mark_favorite_reply_on_own_topic", id.WhoCanMarkFavoriteReplyOnOwnTopic) |
| 299 | + d.Set("who_can_mark_no_response_needed", id.WhoCanMarkNoResponseNeeded) |
| 300 | + d.Set("who_can_moderate_content", id.WhoCanModerateContent) |
| 301 | + d.Set("who_can_moderate_members", id.WhoCanModerateMembers) |
| 302 | + d.Set("who_can_modify_members", id.WhoCanModifyMembers) |
| 303 | + d.Set("who_can_modify_tags_and_categories", id.WhoCanModifyTagsAndCategories) |
| 304 | + d.Set("who_can_move_topics_in", id.WhoCanMoveTopicsIn) |
| 305 | + d.Set("who_can_move_topics_out", id.WhoCanMoveTopicsOut) |
| 306 | + d.Set("who_can_post_announcements", id.WhoCanPostAnnouncements) |
| 307 | + d.Set("who_can_post_message", id.WhoCanPostMessage) |
| 308 | + d.Set("who_can_take_topics", id.WhoCanTakeTopics) |
| 309 | + d.Set("who_can_unassign_topic", id.WhoCanUnassignTopic) |
| 310 | + d.Set("who_can_unmark_favorite_reply_on_any_topic", id.WhoCanUnmarkFavoriteReplyOnAnyTopic) |
| 311 | + d.Set("who_can_view_group", id.WhoCanViewGroup) |
| 312 | + d.Set("who_can_view_membership", id.WhoCanViewMembership) |
| 313 | + |
| 314 | + return nil |
| 315 | +} |
0 commit comments