<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Lock weirdness in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160507#M7239</link>
    <description>&lt;P&gt;It's only really an issue because I would like my data import to be simple. I want to avoid special cases like "I just set this object, so ignore the meta-info fields the returned data has, and use this meta-info I create locally instead."&lt;/P&gt;
&lt;P&gt;The language I'm using is aggressively asynchronous and reactive. All of my response handling (and therefore data importing) is in a callback closure, which doesn't necessarily get to know about the request which resulted in the closure being called. I can spin up a background thread and force a synchronous call (thereby maintaining access to call input), but that's gross for other reasons. Still, might be my best option for now.&lt;/P&gt;
&lt;P&gt;The language is also strongly-typed, which makes the wide assortment of objects returned by 'show objects' interesting to handle, but that's pretty far off-topic.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2022 22:11:21 GMT</pubDate>
    <dc:creator>Bob_Zimmerman</dc:creator>
    <dc:date>2022-10-26T22:11:21Z</dc:date>
    <item>
      <title>Lock weirdness</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/144822#M6673</link>
      <description>&lt;P&gt;Currently using APIv1.7.1, and I've noticed some weird behavior with write locks on objects. When I make a call to change an object like so:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;mgmt_cli -s session.txt -f json set host uid f752bfcd-8194-4831-a8cf-16dabecbac73 ipv4-address 10.20.30.40&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the data returned by the call includes meta-info.lock: "unlocked" and read-only: true. When I later show the same object from the same session like so:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;mgmt_cli -s session.txt -f json show host uid f752bfcd-8194-4831-a8cf-16dabecbac73&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the data returned has meta-info.lock: "&lt;/SPAN&gt;&lt;SPAN&gt;locked by current session" and read-only: false.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Why the difference?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Separately, is there a way in the API to see which objects have a lock besides just downloading everything from scratch? 'show sessions' for the session with the lock shows it has &lt;EM&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;/EM&gt; lock, but doesn't tell you &lt;EM&gt;&lt;STRONG&gt;what&lt;/STRONG&gt;&lt;/EM&gt; it has locked. Specifically, I want to be able to tell what objects have been locked since I started my session, and which sessions have locked them.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 15:23:06 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/144822#M6673</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-03-26T15:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Lock weirdness</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/144931#M6681</link>
      <description>&lt;P&gt;Paging&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/37502"&gt;@Omer_Kleinstern&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 19:25:18 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/144931#M6681</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2022-03-28T19:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Lock weirdness</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160192#M7222</link>
      <description>&lt;P&gt;Coming back to this, I put together a brief script demonstrating the issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Expert@DallasSA]# mgmt_cli -r true login &amp;gt; session.txt
[Expert@DallasSA]# UUID_TO_CHANGE=$(mgmt_cli -f json -s session.txt show hosts limit 1 | jq '.objects[0].uid')
[Expert@DallasSA]# mgmt_cli -f json -s session.txt show host uid "$UUID_TO_CHANGE" details-level full | jq '{readOnly:."read-only",metaInfo:."meta-info"}';mgmt_cli -f json -s session.txt set host uid "$UUID_TO_CHANGE" comments "Testing a change" details-level full | jq '{readOnly:."read-only",metaInfo:."meta-info"}';mgmt_cli -f json -s session.txt show host uid "$UUID_TO_CHANGE" details-level full | jq '{readOnly:."read-only",metaInfo:."meta-info"}'
{
  "readOnly": false,
  "metaInfo": {
    "lock": "unlocked",
    "validation-state": "ok",
    "last-modify-time": {
      "posix": 1637433240653,
      "iso-8601": "2021-11-20T18:34+0000"
    },
    "last-modifier": "WEB_API",
    "creation-time": {
      "posix": 1637433240653,
      "iso-8601": "2021-11-20T18:34+0000"
    },
    "creator": "WEB_API"
  }
}
{
  "readOnly": true,
  "metaInfo": {
    "lock": "unlocked",
    "validation-state": "ok",
    "last-modify-time": {
      "posix": 1666550291300,
      "iso-8601": "2022-10-23T18:38+0000"
    },
    "last-modifier": "WEB_API",
    "creation-time": {
      "posix": 1637433240653,
      "iso-8601": "2021-11-20T18:34+0000"
    },
    "creator": "WEB_API"
  }
}
{
  "readOnly": false,
  "metaInfo": {
    "lock": "locked by current session",
    "validation-state": "ok",
    "last-modify-time": {
      "posix": 1666550291300,
      "iso-8601": "2022-10-23T18:38+0000"
    },
    "last-modifier": "WEB_API",
    "creation-time": {
      "posix": 1637433240653,
      "iso-8601": "2021-11-20T18:34+0000"
    },
    "creator": "WEB_API"
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still on API v1.7.1 (R81 jumbo 74).&lt;/P&gt;
&lt;P&gt;The main command generates a before-change output, the output from the change call, then an after-change output. The change output updates the read-only property to true, and the meta-info.last-modify-time gets updated, but the meta-info.lock property stays "unlocked". Then immediately after the change, the read-only property goes back to false and the meta-info.lock updates to say it's locked by the current session.&lt;/P&gt;
&lt;P&gt;Is this expected behavior? Seems weird to not immediately show the object is locked by the current session. The brief trip through read-only: true is also strange.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Oct 2022 18:46:03 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160192#M7222</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-10-23T18:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Lock weirdness</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160276#M7226</link>
      <description>&lt;P&gt;Sounds weird to me also.&lt;BR /&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/37502"&gt;@Omer_Kleinstern&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 17:58:33 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160276#M7226</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2022-10-24T17:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Lock weirdness</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160502#M7238</link>
      <description>&lt;P&gt;Looks like an issue.&lt;/P&gt;
&lt;P&gt;Why is this property&amp;nbsp;interesting in this case? When a SET command on a network object is&amp;nbsp;completed successfully, the object is&amp;nbsp;definitely&amp;nbsp;&lt;SPAN&gt;locked by the current session.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 21:10:50 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160502#M7238</guid>
      <dc:creator>Omer_Kleinstern</dc:creator>
      <dc:date>2022-10-26T21:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Lock weirdness</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160507#M7239</link>
      <description>&lt;P&gt;It's only really an issue because I would like my data import to be simple. I want to avoid special cases like "I just set this object, so ignore the meta-info fields the returned data has, and use this meta-info I create locally instead."&lt;/P&gt;
&lt;P&gt;The language I'm using is aggressively asynchronous and reactive. All of my response handling (and therefore data importing) is in a callback closure, which doesn't necessarily get to know about the request which resulted in the closure being called. I can spin up a background thread and force a synchronous call (thereby maintaining access to call input), but that's gross for other reasons. Still, might be my best option for now.&lt;/P&gt;
&lt;P&gt;The language is also strongly-typed, which makes the wide assortment of objects returned by 'show objects' interesting to handle, but that's pretty far off-topic.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 22:11:21 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Lock-weirdness/m-p/160507#M7239</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-10-26T22:11:21Z</dc:date>
    </item>
  </channel>
</rss>

