scottdware / go-bigip

A Go package that interacts with F5 BIG-IP systems using the REST API.
MIT License
108 stars 118 forks source link

add patch method and use patch in AddMonitorToPool #52

Closed zetaab closed 6 years ago

zetaab commented 6 years ago

Fixes #13

GET https://xxx/mgmt/tm/ltm/pool/demoapp-test_80

{
  "kind": "tm:ltm:pool:poolstate",
  "name": "demoapp-test_80",
  "fullPath": "demoapp-test_80",
  "generation": 1457,
  "selfLink": "https://localhost/mgmt/tm/ltm/pool/demoapp-test_80?ver=12.1.2",
  "allowNat": "yes",
  "allowSnat": "yes",
  "ignorePersistedWeight": "disabled",
  "ipTosToClient": "pass-through",
  "ipTosToServer": "pass-through",
  "linkQosToClient": "pass-through",
  "linkQosToServer": "pass-through",
  "loadBalancingMode": "ratio-node",
  "minActiveMembers": 1,
  "minUpMembers": 0,
  "minUpMembersAction": "failover",
  "minUpMembersChecking": "disabled",
  "queueDepthLimit": 0,
  "queueOnConnectionLimit": "disabled",
  "queueTimeLimit": 0,
  "reselectTries": 0,
  "serviceDownAction": "none",
  "slowRampTime": 10,
  "membersReference": {
    "link": "https://localhost/mgmt/tm/ltm/pool/~Common~demoapp-test_80/members?ver=12.1.2",
    "isSubcollection": true
  }
}

Then we will send

PUT https://xxx/mgmt/tm/ltm/pool/demoapp-test_80 and data

{"monitor":"demoapp-test_80"}

The system will reply back

{
  "kind": "tm:ltm:pool:poolstate",
  "name": "demoapp-test_80",
  "fullPath": "demoapp-test_80",
  "generation": 1463,
  "selfLink": "https://localhost/mgmt/tm/ltm/pool/demoapp-test_80?ver=12.1.2",
  "allowNat": "yes",
  "allowSnat": "yes",
  "ignorePersistedWeight": "disabled",
  "ipTosToClient": "pass-through",
  "ipTosToServer": "pass-through",
  "linkQosToClient": "pass-through",
  "linkQosToServer": "pass-through",
  "loadBalancingMode": "round-robin",
  "minActiveMembers": 0,
  "minUpMembers": 0,
  "minUpMembersAction": "failover",
  "minUpMembersChecking": "disabled",
  "monitor": "/Common/demoapp-test_80 ",
  "queueDepthLimit": 0,
  "queueOnConnectionLimit": "disabled",
  "queueTimeLimit": 0,
  "reselectTries": 0,
  "serviceDownAction": "none",
  "slowRampTime": 10,
  "membersReference": {
    "link": "https://localhost/mgmt/tm/ltm/pool/~Common~demoapp-test_80/members?ver=12.1.2",
    "isSubcollection": true
  }
}

Using PATCH method minActiveMembers and loadBalancingMode stays same as before.

From the REST guide "To address different requirements, iControl REST implements both PATCH and PUT methods. In iControl REST, the PATCH method modifies only the properties that you specify in a request. The PUT method modifies the properties that you specify in a request and sets the remaining properties to either default values or empty values."