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

Feature Request: Resource for Netbox User Permissions #387

Closed
tagur87 opened this issue Apr 25, 2023 · 1 comment
Closed

Feature Request: Resource for Netbox User Permissions #387

tagur87 opened this issue Apr 25, 2023 · 1 comment

Comments

@tagur87
Copy link
Contributor

tagur87 commented Apr 25, 2023

We'd like to request adding a new resource for managing netbox user permissions.

This is based on an API call like below:

curl -s -X POST $NETBOX_SERVER_URL/api/users/permissions/ \
    -H "Authorization: Token $NETBOX_API_TOKEN" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json; indent=4" \
    -d "{
        \"name\": \"ro_user_permission\",
        \"description\": "Read Only",
        \"enabled\": true,
        \"object_types\": [\"auth.user\"],
        \"actions\": [\"view\"],
        \"users\": [1],
       \"groups\": [1]

We'd like to propose a resource name like netbox_user_permissions for this new resource.

We may be able to submit a PR with this, but not sure depending on time.

Thanks!

tagur87 added a commit to tagur87/terraform-provider-netbox that referenced this issue Apr 27, 2023
This feature allows management of netbox user permissions with
terraform. It follows the pattern of testing and design similar to that
of other resources.

A unique feature of this resource is the handling of the `constraints`
field. Since this field is a JSON blob in the netbox API, we had to
find a nice way to convert a JSON string into a JSON blob. And since
this field can be either a JSON list or a JSON object, we had to handle
this accordingly. By using `json.Unmarshal()` on the string, and then
doing a type switch, we could detect the correct type, and set that in
the struct for sending it to the API.

Ref: e-breuninger#387
fbreckle pushed a commit to tagur87/terraform-provider-netbox that referenced this issue May 7, 2023
This feature allows management of netbox user permissions with
terraform. It follows the pattern of testing and design similar to that
of other resources.

A unique feature of this resource is the handling of the `constraints`
field. Since this field is a JSON blob in the netbox API, we had to
find a nice way to convert a JSON string into a JSON blob. And since
this field can be either a JSON list or a JSON object, we had to handle
this accordingly. By using `json.Unmarshal()` on the string, and then
doing a type switch, we could detect the correct type, and set that in
the struct for sending it to the API.

Ref: e-breuninger#387
fbreckle pushed a commit that referenced this issue May 7, 2023
This feature allows management of netbox user permissions with
terraform. It follows the pattern of testing and design similar to that
of other resources.

A unique feature of this resource is the handling of the `constraints`
field. Since this field is a JSON blob in the netbox API, we had to
find a nice way to convert a JSON string into a JSON blob. And since
this field can be either a JSON list or a JSON object, we had to handle
this accordingly. By using `json.Unmarshal()` on the string, and then
doing a type switch, we could detect the correct type, and set that in
the struct for sending it to the API.

Ref: #387
@fbreckle
Copy link
Collaborator

fbreckle commented May 7, 2023

Closed by #390

@fbreckle fbreckle closed this as completed May 7, 2023
twink0r pushed a commit to twink0r/terraform-provider-netbox that referenced this issue Sep 15, 2023
This feature allows management of netbox user permissions with
terraform. It follows the pattern of testing and design similar to that
of other resources.

A unique feature of this resource is the handling of the `constraints`
field. Since this field is a JSON blob in the netbox API, we had to
find a nice way to convert a JSON string into a JSON blob. And since
this field can be either a JSON list or a JSON object, we had to handle
this accordingly. By using `json.Unmarshal()` on the string, and then
doing a type switch, we could detect the correct type, and set that in
the struct for sending it to the API.

Ref: e-breuninger#387
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants