deploymenttheory / go-api-sdk-jamfpro

A jamf pro api sdk written in go that can perform CRUD operations against both the classic and jamf pro api. Includes an examples and recipes library demonstrating usage
Mozilla Public License 2.0
14 stars 8 forks source link

Bug report 🐛 - endpoint of Computer Groups Creation might need to change #559

Closed Haraguroicha closed 2 weeks ago

Haraguroicha commented 2 weeks ago

Description

Please describe your bug as detailed as possible.

since the current version, I got "HTTP Status 404 – Not Found", which might need to be changed with a suffix /id/0 to get it to work

reference document: https://developer.jamf.com/jamf-pro/reference/createcomputergroupbyid

https://github.com/deploymenttheory/go-api-sdk-jamfpro/blob/ae01a7c892fb9db586d81f0dc247aba31ddab688/sdk/jamfpro/classicapi_computer_groups.go#L124

@@ -1,124 +1,124 @@
-endpoint := uriComputerGroups
+endpoint := fmt.Sprintf("%s/id/0", uriComputerGroups)

Steps to reproduce

  1. Create Smart Group or Static Group

Screenshots

ShocOne commented 2 weeks ago

hi there, please can you confirm what version of jamf pro you are using please. thanks

ShocOne commented 2 weeks ago

For added detail, when i leverage the create example for CreateSmartComputerGroup my create operation is successful.

dafyddwatkins@Dafydds-MacBook-Air CreateSmartComputerGroup % go run '/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/examples/jamf_pro_version/GetJamfProVersion/GetJamfProVersion.go'
Current Jamf Pro Version: 11.10.2-t1729874551
dafyddwatkins@Dafydds-MacBook-Air CreateSmartComputerGroup % go run '/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/examples/smart_computer_groups/CreateSmartComputerGroup/CreateSmartComputerGroup.go'
Created Computer Group:
 <ResponseComputerGroupreatedAndUpdated>
    <id>5</id>
</ResponseComputerGroupreatedAndUpdated>
dafyddwatkins@Dafydds-MacBook-Air CreateSmartComputerGroup % 
Haraguroicha commented 2 weeks ago

Hi @ShocOne

I'm using JamfCloud Version 11.10.2-t1729874551 instance with https://github.com/deploymenttheory/terraform-provider-jamfpro/releases/tag/v0.4.3 to provision SmartComputerGroup, but get an error message with HTTP Status 404 – Not Found

│ Error: failed to create  after retries: failed to create computer group, error: {"status_code":404,"method":"POST","url":"https://xxxxxxxxx.jamfcloud.com//JSSResource/computergroups","message":"HTML Error: See 'Raw' field for details.","raw_response":"\u003c!doctype html\u003e\u003chtml lang=\"en\"\u003e\u003chead\u003e\u003ctitle\u003eHTTP Status 404 – Not Found\u003c/title\u003e\u003cstyle type=\"text/css\"\u003ebody {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}\u003c/style\u003e\u003c/head\u003e\u003cbody\u003e\u003ch1\u003eHTTP Status 404 – Not Found\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e"}
│ 
│   with jamfpro_smart_computer_group.Computers,
│   on jamfpro_smart_computer_group.tf line 1, in resource "jamfpro_smart_computer_group" "Computers":
│    1: resource "jamfpro_smart_computer_group" "Computers" {

tf resource:

resource "jamfpro_smart_computer_group" "Computers" {
  name = "Computers"
  criteria {
    priority = 0
    name = "Computer Group"
    search_type = "member of"
    value = "All Managed Clients"
    opening_paren = true
  }
  criteria {
    priority = 1
    and_or = "or"
    name = "Computer Group"
    search_type = "member of"
    value = "All Managed Servers"
    closing_paren = true
  }
}
ShocOne commented 2 weeks ago

two points. first, this issue should be logged under the terraform jamfpro repo. secondly, your hcl works within my environment


2024-11-05T19:27:30.520Z [DEBUG] provider.terraform-provider-jamfpro: Constructed Jamf Pro Computer Group XML:
<ResourceComputerGroup>
  <id>0</id>
  <name>Computers_bugfix</name>
  <is_smart>true</is_smart>
  <site>
    <id>-1</id>
  </site>
  <criteria>
    <size>2</size>
    <criterion>
      <name>Computer Group</name>
      <and_or>and</and_or>
      <search_type>member of</search_type>
      <value>All Managed Clients</value>
      <opening_paren>true</opening_paren>
    </criterion>
    <criterion>
      <name>Computer Group</name>
      <priority>1</priority>
      <and_or>or</and_or>
      <search_type>member of</search_type>
      <value>All Managed Servers</value>
      <closing_paren>true</closing_paren>
    </criterion>
  </criteria>
</ResourceComputerGroup>: timestamp=2024-11-05T19:27:30.520Z
2024-11-05T19:27:30.520Z [DEBUG] provider.terraform-provider-jamfpro: Waiting for state to become: [success]: timestamp=2024-11-05T19:27:30.520Z
2024-11-05T19:27:30.832Z [DEBUG] provider.terraform-provider-jamfpro: Waiting for state to become: [success]: timestamp=2024-11-05T19:27:30.831Z
jamfpro_smart_computer_group.Computers: Creation complete after 0s [id=10]
2024-11-05T19:27:31.079Z [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-11-05T19:27:31.081Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-11-05T19:27:31.084Z [INFO]  provider: plugin process exited: plugin=.terraform/providers/terraform.local/local/jamfpro/0.1.0/darwin_arm64/terraform-provider-jamfpro id=19828
2024-11-05T19:27:31.084Z [DEBUG] provider: plugin exited

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
dafyddwatkins@Dafydds-MacBook-Air terraform % 

are you sure both those groups actually exist in your jamf instance ?. closing bug, please relog within the correct repo and provide screenshots of the nested groups as well if the issue persists. thanks

Haraguroicha commented 2 weeks ago

Hi @ShocOne

Both of the groups are default smart groups which are automaticlly created during the instance creation process, after I checked the log with the previous successful log, I confirmed that was a Jamf Pro Product Issue for starting with a double slash in the path will break the group creation process.