{"action":"created","comment":{"url":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/comments/66992540","id":66992540,"diff_hunk":"@@ -0,0 +1,156 @@\n+# June 2016, Charles Burkett\n+#\n+# Copyright (c) 2015-2016 Cisco and/or its affiliates.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+require 'json'\n+\n+module Cisco\n+  # class Cisco::Yang\n+  # Utility class mainly containing methods to compare YANG configurations\n+  # in order to determine if the running config is in-sync with the\n+  # desired config.\n+  class Yang\n+    # Is the specified yang string empty?\n+    def self.empty?(yang)\n+      !yang || yang.empty?\n+    end\n+\n+    # Given a current and target YANG configuration, returns true if\n+    # the configurations are in-sync, relative to a \"merge_config\" action\n+    def self.insync_for_merge?(target, current)\n+      target_hash = self.empty?(target) ? {} : JSON.parse(target)\n+      current_hash = self.empty?(current) ? {} : JSON.parse(current)\n+\n+      !needs_something?(:merge, target_hash, current_hash)\n+    end\n+\n+    # Given a current and target YANG configuration, returns true if\n+    # the configuration are in-sync, relative to a \"replace_config\" action\n+    def self.insync_for_replace?(target, current)\n+      target_hash = self.empty?(target) ? {} : JSON.parse(target)\n+      current_hash = self.empty?(current) ? {} : JSON.parse(current)\n+\n+      !needs_something?(:replace, target_hash, current_hash)\n+    end\n+\n+    # usage:\n+    #   needs_something?(op, target, run)\n+    #\n+    #   op     - symbol - If value is not :replace, it's assumed to be :merge.\n+    #                     Indicates to the function whether to check for a\n+    #                     possible merge vs. replace\n+    #\n+    #   target - JSON   - JSON tree representing target configuration\n+    #\n+    #   run    - JSON   - JSON tree representing target configuration","path":"lib/cisco_node_utils/yang.rb","position":57,"original_position":57,"commit_id":"193eded140b4843fd499b80bd9988faf104a7aed","original_commit_id":"193eded140b4843fd499b80bd9988faf104a7aed","user":{"login":"mikewiebe","id":12445795,"avatar_url":"https://avatars.githubusercontent.com/u/12445795?v=3","gravatar_id":"","url":"https://api.github.com/users/mikewiebe","html_url":"https://github.com/mikewiebe","followers_url":"https://api.github.com/users/mikewiebe/followers","following_url":"https://api.github.com/users/mikewiebe/following{/other_user}","gists_url":"https://api.github.com/users/mikewiebe/gists{/gist_id}","starred_url":"https://api.github.com/users/mikewiebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikewiebe/subscriptions","organizations_url":"https://api.github.com/users/mikewiebe/orgs","repos_url":"https://api.github.com/users/mikewiebe/repos","events_url":"https://api.github.com/users/mikewiebe/events{/privacy}","received_events_url":"https://api.github.com/users/mikewiebe/received_events","type":"User","site_admin":false},"body":"Should this read `run    - JSON    - JSON tree representing current configuration` ?","created_at":"2016-06-14T15:21:44Z","updated_at":"2016-06-14T15:21:44Z","html_url":"https://github.com/cisco/cisco-network-node-utils/pull/425#discussion_r66992540","pull_request_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425","_links":{"self":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/comments/66992540"},"html":{"href":"https://github.com/cisco/cisco-network-node-utils/pull/425#discussion_r66992540"},"pull_request":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425"}}},"pull_request":{"url":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425","id":73590242,"html_url":"https://github.com/cisco/cisco-network-node-utils/pull/425","diff_url":"https://github.com/cisco/cisco-network-node-utils/pull/425.diff","patch_url":"https://github.com/cisco/cisco-network-node-utils/pull/425.patch","issue_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/issues/425","number":425,"state":"open","locked":false,"title":"YANG JSON support for gRPC client","user":{"login":"chburket","id":15893389,"avatar_url":"https://avatars.githubusercontent.com/u/15893389?v=3","gravatar_id":"","url":"https://api.github.com/users/chburket","html_url":"https://github.com/chburket","followers_url":"https://api.github.com/users/chburket/followers","following_url":"https://api.github.com/users/chburket/following{/other_user}","gists_url":"https://api.github.com/users/chburket/gists{/gist_id}","starred_url":"https://api.github.com/users/chburket/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chburket/subscriptions","organizations_url":"https://api.github.com/users/chburket/orgs","repos_url":"https://api.github.com/users/chburket/repos","events_url":"https://api.github.com/users/chburket/events{/privacy}","received_events_url":"https://api.github.com/users/chburket/received_events","type":"User","site_admin":false},"body":"This PR adds support for getting/setting config in YANG JSON format over gRPC.\r\n\r\n### Tested Platforms\r\n\r\n* xrv9k\r\n* n9kv\r\n\r\nI ran the full set of minitests on n9kv and there were many failures/errors, but none of them seemed to be due to my changes, and the errors were reported properly (indicating the changes to the error handling code still work properly on nexus).","created_at":"2016-06-13T15:00:16Z","updated_at":"2016-06-14T15:21:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79eeb0903160c9dd3c72c4e9115a0beab2743371","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425/commits","review_comments_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425/comments","review_comment_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/issues/425/comments","statuses_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/statuses/193eded140b4843fd499b80bd9988faf104a7aed","head":{"label":"chburket:develop","ref":"develop","sha":"193eded140b4843fd499b80bd9988faf104a7aed","user":{"login":"chburket","id":15893389,"avatar_url":"https://avatars.githubusercontent.com/u/15893389?v=3","gravatar_id":"","url":"https://api.github.com/users/chburket","html_url":"https://github.com/chburket","followers_url":"https://api.github.com/users/chburket/followers","following_url":"https://api.github.com/users/chburket/following{/other_user}","gists_url":"https://api.github.com/users/chburket/gists{/gist_id}","starred_url":"https://api.github.com/users/chburket/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chburket/subscriptions","organizations_url":"https://api.github.com/users/chburket/orgs","repos_url":"https://api.github.com/users/chburket/repos","events_url":"https://api.github.com/users/chburket/events{/privacy}","received_events_url":"https://api.github.com/users/chburket/received_events","type":"User","site_admin":false},"repo":{"id":52386870,"name":"cisco-network-node-utils","full_name":"chburket/cisco-network-node-utils","owner":{"login":"chburket","id":15893389,"avatar_url":"https://avatars.githubusercontent.com/u/15893389?v=3","gravatar_id":"","url":"https://api.github.com/users/chburket","html_url":"https://github.com/chburket","followers_url":"https://api.github.com/users/chburket/followers","following_url":"https://api.github.com/users/chburket/following{/other_user}","gists_url":"https://api.github.com/users/chburket/gists{/gist_id}","starred_url":"https://api.github.com/users/chburket/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chburket/subscriptions","organizations_url":"https://api.github.com/users/chburket/orgs","repos_url":"https://api.github.com/users/chburket/repos","events_url":"https://api.github.com/users/chburket/events{/privacy}","received_events_url":"https://api.github.com/users/chburket/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chburket/cisco-network-node-utils","description":"","fork":true,"url":"https://api.github.com/repos/chburket/cisco-network-node-utils","forks_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/forks","keys_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/teams","hooks_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/hooks","issue_events_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/issues/events{/number}","events_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/events","assignees_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/assignees{/user}","branches_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/branches{/branch}","tags_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/tags","blobs_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/languages","stargazers_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/stargazers","contributors_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/contributors","subscribers_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/subscribers","subscription_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/subscription","commits_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/contents/{+path}","compare_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/merges","archive_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/downloads","issues_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/issues{/number}","pulls_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/labels{/name}","releases_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/releases{/id}","deployments_url":"https://api.github.com/repos/chburket/cisco-network-node-utils/deployments","created_at":"2016-02-23T19:48:31Z","updated_at":"2016-02-23T19:48:32Z","pushed_at":"2016-06-13T15:03:38Z","git_url":"git://github.com/chburket/cisco-network-node-utils.git","ssh_url":"git@github.com:chburket/cisco-network-node-utils.git","clone_url":"https://github.com/chburket/cisco-network-node-utils.git","svn_url":"https://github.com/chburket/cisco-network-node-utils","homepage":null,"size":3503,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"cisco:develop","ref":"develop","sha":"9e252098b6a95b45fd4bc1aaa8cdae44c43891d3","user":{"login":"cisco","id":1376999,"avatar_url":"https://avatars.githubusercontent.com/u/1376999?v=3","gravatar_id":"","url":"https://api.github.com/users/cisco","html_url":"https://github.com/cisco","followers_url":"https://api.github.com/users/cisco/followers","following_url":"https://api.github.com/users/cisco/following{/other_user}","gists_url":"https://api.github.com/users/cisco/gists{/gist_id}","starred_url":"https://api.github.com/users/cisco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cisco/subscriptions","organizations_url":"https://api.github.com/users/cisco/orgs","repos_url":"https://api.github.com/users/cisco/repos","events_url":"https://api.github.com/users/cisco/events{/privacy}","received_events_url":"https://api.github.com/users/cisco/received_events","type":"Organization","site_admin":false},"repo":{"id":39565196,"name":"cisco-network-node-utils","full_name":"cisco/cisco-network-node-utils","owner":{"login":"cisco","id":1376999,"avatar_url":"https://avatars.githubusercontent.com/u/1376999?v=3","gravatar_id":"","url":"https://api.github.com/users/cisco","html_url":"https://github.com/cisco","followers_url":"https://api.github.com/users/cisco/followers","following_url":"https://api.github.com/users/cisco/following{/other_user}","gists_url":"https://api.github.com/users/cisco/gists{/gist_id}","starred_url":"https://api.github.com/users/cisco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cisco/subscriptions","organizations_url":"https://api.github.com/users/cisco/orgs","repos_url":"https://api.github.com/users/cisco/repos","events_url":"https://api.github.com/users/cisco/events{/privacy}","received_events_url":"https://api.github.com/users/cisco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cisco/cisco-network-node-utils","description":"","fork":false,"url":"https://api.github.com/repos/cisco/cisco-network-node-utils","forks_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/forks","keys_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/teams","hooks_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/hooks","issue_events_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/issues/events{/number}","events_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/events","assignees_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/assignees{/user}","branches_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/branches{/branch}","tags_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/tags","blobs_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/languages","stargazers_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/stargazers","contributors_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/contributors","subscribers_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/subscribers","subscription_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/subscription","commits_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/contents/{+path}","compare_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/merges","archive_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/downloads","issues_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/issues{/number}","pulls_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/labels{/name}","releases_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/releases{/id}","deployments_url":"https://api.github.com/repos/cisco/cisco-network-node-utils/deployments","created_at":"2015-07-23T12:07:39Z","updated_at":"2016-05-23T07:33:11Z","pushed_at":"2016-06-13T19:04:51Z","git_url":"git://github.com/cisco/cisco-network-node-utils.git","ssh_url":"git@github.com:cisco/cisco-network-node-utils.git","clone_url":"https://github.com/cisco/cisco-network-node-utils.git","svn_url":"https://github.com/cisco/cisco-network-node-utils","homepage":null,"size":5491,"stargazers_count":14,"watchers_count":14,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":37,"mirror_url":null,"open_issues_count":3,"forks":37,"open_issues":3,"watchers":14,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425"},"html":{"href":"https://github.com/cisco/cisco-network-node-utils/pull/425"},"issue":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/issues/425"},"comments":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/issues/425/comments"},"review_comments":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425/comments"},"review_comment":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/pulls/425/commits"},"statuses":{"href":"https://api.github.com/repos/cisco/cisco-network-node-utils/statuses/193eded140b4843fd499b80bd9988faf104a7aed"}}}}
{"actor":{"display_login":"mikewiebe"}}