Yohan460 / terraform-provider-jamf

Other
14 stars 10 forks source link

Add User groups for resources and data sources #17

Open ecanault opened 1 year ago

ecanault commented 1 year ago

Hi,

This is a followup of #12 to request Smart user groups and Static user groups support for resources and data sources.

Description

Classic API Endpoint for User groups is described here:

Endpoint URL: https://yourServer.jamfcloud.com/JSSResource/usergroups/id/{id}

Sample request body for PUT and POST for smart user group (setting is_smart to true):

<user_group>
    <name>Teachers</name>
    <is_smart>true</is_smart>
    <is_notify_on_change>true</is_notify_on_change>
    <site>
        <id>-1</id>
        <name>None</name>
    </site>
    <criteria>
        <criterion>
            <name>Email Address</name>
            <priority>0</priority>
            <and_or>and</and_or>
            <search_type>like</search_type>
            <value>company.com</value>
            <opening_paren>false</opening_paren>
            <closing_paren>false</closing_paren>
        </criterion>
    </criteria>
</user_group>

Sample request body for PUT and POST for static user group (setting is_smart to false):

<user_group>
    <name>Static Group</name>
    <is_smart>false</is_smart>
    <is_notify_on_change>false</is_notify_on_change>
    <site>
        <id>-1</id>
        <name>None</name>
    </site>
    <users>
        <user>
            <id>1938</id>
            <username>Mercy</username>
            <full_name/>
            <phone_number/>
            <email_address>mercy@company.com</email_address>
        </user>
        <user>
            <id>1939</id>
            <username>Aaron</username>
            <full_name/>
            <phone_number/>
            <email_address>aaron@company.com</email_address>
        </user>
    </users>
</user_group>

Required parameter for every type of request: id, set to 0 for a POST request.

Sample Go code for each method is available on the pages above, but I don't have the knowledge to develop this by myself. I hope I'm doing it the good way to ask this, and thank you for creating a PR if you find this enhancement helpful!