{"action":"created","comment":{"url":"https://api.github.com/repos/CESNET/perun-services/pulls/comments/78149848","id":78149848,"diff_hunk":"@@ -0,0 +1,104 @@\n+#!/usr/bin/perl\n+\n+# Generates members of o365 service in JSON format\n+\n+use strict;\n+use warnings;\n+use perunServicesInit;\n+use perunServicesUtils;\n+use JSON::XS;\n+\n+sub processMembers;\n+\n+our $SERVICE_NAME     = \"o365\";\n+our $PROTOCOL_VERSION = \"3.0.0\";\n+my $SCRIPT_VERSION = \"3.0.0\";\n+\n+perunServicesInit::init;\n+my $DIRECTORY = perunServicesInit::getDirectory;\n+my $data      = perunServicesInit::getHierarchicalData;\n+\n+our $A_USER_FIRST_NAME;         *A_USER_FIRST_NAME =            \\'urn:perun:user:attribute-def:core:firstName';\n+our $A_USER_LAST_NAME;          *A_USER_LAST_NAME =             \\'urn:perun:user:attribute-def:core:lastName';\n+our $A_USER_DISPLAY_NAME;       *A_USER_DISPLAY_NAME =          \\'urn:perun:user:attribute-def:core:displayName';\n+our $A_USER_PREFERRED_MAIL;     *A_USER_PREFERRED_MAIL =        \\'urn:perun:user:attribute-def:def:preferredMail';\n+our $A_USER_USER_TYPE;          *A_USER_USER_TYPE =             \\'urn:perun:user:attribute-def:def:o365-userType';\n+our $A_USER_ASSIGNED_LICENSES;  *A_USER_ASSIGNED_LICENSES =     \\'urn:perun:user:attribute-def:def:o365-assignedLicenses';\n+our $A_USER_PHOTO;              *A_USER_PHOTO =                 \\'urn:perun:user:attribute-def:def:o365-userPhoto';\n+\n+our $outputData = {value => [],};\n+our $members = {};\n+\n+foreach my $resourceData ($data->getChildElements) {\n+    my @membersData = $resourceData->getChildElements;\n+\n+    processMembers(\\@membersData);\n+}\n+\n+# format of 1 line in photos.csv file:\n+# userPrincipalName,base64 photo encoding\n+my $filePhotos= $DIRECTORY . \"photos.csv\";\n+open FILE_PHOTOS, \">$filePhotos\" or die \"Cannot open $filePhotos: $! \\n\";\n+\n+foreach my $mail (sort keys %{$members}) {\n+    my $member = $members->{$mail};\n+\n+\tif(defined $member->{'photo'}) {\n+\t\tprint FILE_PHOTOS \"$mail,$member->{'photo'}\", \"\\n\";\n+\t}\n+\n+\tpush @{$outputData->{'value'}}, $member;\n+}\n+\n+close(FILE_PHOTOS) or die \"Cannot close $filePhotos: $! \\n\";\n+\n+# format of 1 user in users.json file:\n+# {\n+# \t\"accountEnabled\":true,\n+# \t\"assignedLicenses\":[\"license1\",\"license2\"],\n+# \t\"displayName\":\"James Bond\",\n+# \t\"givenName\":\"James\",\n+# \t\"mail\":\"james.bond@agent.com\",\n+# \t\"preferredName\":\"jamesb\",\n+# \t\"surname\":\"Bond\",\n+# \t\"usageLocation\":\"CZ\",\n+# \t\"userPrincipalName\":\"james.bond@agent.com\",\n+# \t\"userType\":\"member\"\n+#\t\"photo\":\"base64string\"\n+# }\n+my $fileUsers = $DIRECTORY . \"users.json\";\n+open FILE_USERS, \">$fileUsers\" or die \"Cannot open $fileUsers: $! \\n\";\n+print FILE_USERS JSON::XS->new->utf8->encode($outputData), \"\\n\";\n+close(FILE_USERS) or die \"Cannot close $fileUsers: $! \\n\";\n+\n+perunServicesInit::finalize;\n+\n+##############################################################################\n+#   Only subs definitions down there\n+##############################################################################\n+\n+sub processMembers {\n+\tmy @membersData =  @{$_[0]};\n+\n+\tforeach my $memberData (dataToAttributesHashes @membersData) {\n+\t\tmy $mail = $memberData->{$A_USER_PREFERRED_MAIL};\n+        my $member = {\n+                        accountEnabled   => \\1,","path":"gen/o365","position":86,"original_position":86,"commit_id":"2a72274b41683d792516196680bb532cdaf44902","original_commit_id":"2a72274b41683d792516196680bb532cdaf44902","user":{"login":"licehammer","id":3735955,"avatar_url":"https://avatars.githubusercontent.com/u/3735955?v=3","gravatar_id":"","url":"https://api.github.com/users/licehammer","html_url":"https://github.com/licehammer","followers_url":"https://api.github.com/users/licehammer/followers","following_url":"https://api.github.com/users/licehammer/following{/other_user}","gists_url":"https://api.github.com/users/licehammer/gists{/gist_id}","starred_url":"https://api.github.com/users/licehammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/licehammer/subscriptions","organizations_url":"https://api.github.com/users/licehammer/orgs","repos_url":"https://api.github.com/users/licehammer/repos","events_url":"https://api.github.com/users/licehammer/events{/privacy}","received_events_url":"https://api.github.com/users/licehammer/received_events","type":"User","site_admin":false},"body":"Are you sure about using  \"\\1\"? Don't you want \"accountEnabled   => 1,\" instead?","created_at":"2016-09-09T09:08:03Z","updated_at":"2016-09-09T09:08:03Z","html_url":"https://github.com/CESNET/perun-services/pull/107#discussion_r78149848","pull_request_url":"https://api.github.com/repos/CESNET/perun-services/pulls/107","_links":{"self":{"href":"https://api.github.com/repos/CESNET/perun-services/pulls/comments/78149848"},"html":{"href":"https://github.com/CESNET/perun-services/pull/107#discussion_r78149848"},"pull_request":{"href":"https://api.github.com/repos/CESNET/perun-services/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/CESNET/perun-services/pulls/107","id":84040874,"html_url":"https://github.com/CESNET/perun-services/pull/107","diff_url":"https://github.com/CESNET/perun-services/pull/107.diff","patch_url":"https://github.com/CESNET/perun-services/pull/107.patch","issue_url":"https://api.github.com/repos/CESNET/perun-services/issues/107","number":107,"state":"open","locked":false,"title":"Added O365 service","user":{"login":"Laliska","id":8018833,"avatar_url":"https://avatars.githubusercontent.com/u/8018833?v=3","gravatar_id":"","url":"https://api.github.com/users/Laliska","html_url":"https://github.com/Laliska","followers_url":"https://api.github.com/users/Laliska/followers","following_url":"https://api.github.com/users/Laliska/following{/other_user}","gists_url":"https://api.github.com/users/Laliska/gists{/gist_id}","starred_url":"https://api.github.com/users/Laliska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Laliska/subscriptions","organizations_url":"https://api.github.com/users/Laliska/orgs","repos_url":"https://api.github.com/users/Laliska/repos","events_url":"https://api.github.com/users/Laliska/events{/privacy}","received_events_url":"https://api.github.com/users/Laliska/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-05T21:42:02Z","updated_at":"2016-09-09T09:08:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e80ae773f54010a380691d333f041b552943402","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CESNET/perun-services/pulls/107/commits","review_comments_url":"https://api.github.com/repos/CESNET/perun-services/pulls/107/comments","review_comment_url":"https://api.github.com/repos/CESNET/perun-services/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CESNET/perun-services/issues/107/comments","statuses_url":"https://api.github.com/repos/CESNET/perun-services/statuses/2a72274b41683d792516196680bb532cdaf44902","head":{"label":"Laliska:o365","ref":"o365","sha":"2a72274b41683d792516196680bb532cdaf44902","user":{"login":"Laliska","id":8018833,"avatar_url":"https://avatars.githubusercontent.com/u/8018833?v=3","gravatar_id":"","url":"https://api.github.com/users/Laliska","html_url":"https://github.com/Laliska","followers_url":"https://api.github.com/users/Laliska/followers","following_url":"https://api.github.com/users/Laliska/following{/other_user}","gists_url":"https://api.github.com/users/Laliska/gists{/gist_id}","starred_url":"https://api.github.com/users/Laliska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Laliska/subscriptions","organizations_url":"https://api.github.com/users/Laliska/orgs","repos_url":"https://api.github.com/users/Laliska/repos","events_url":"https://api.github.com/users/Laliska/events{/privacy}","received_events_url":"https://api.github.com/users/Laliska/received_events","type":"User","site_admin":false},"repo":{"id":36506866,"name":"perun-services","full_name":"Laliska/perun-services","owner":{"login":"Laliska","id":8018833,"avatar_url":"https://avatars.githubusercontent.com/u/8018833?v=3","gravatar_id":"","url":"https://api.github.com/users/Laliska","html_url":"https://github.com/Laliska","followers_url":"https://api.github.com/users/Laliska/followers","following_url":"https://api.github.com/users/Laliska/following{/other_user}","gists_url":"https://api.github.com/users/Laliska/gists{/gist_id}","starred_url":"https://api.github.com/users/Laliska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Laliska/subscriptions","organizations_url":"https://api.github.com/users/Laliska/orgs","repos_url":"https://api.github.com/users/Laliska/repos","events_url":"https://api.github.com/users/Laliska/events{/privacy}","received_events_url":"https://api.github.com/users/Laliska/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Laliska/perun-services","description":"","fork":true,"url":"https://api.github.com/repos/Laliska/perun-services","forks_url":"https://api.github.com/repos/Laliska/perun-services/forks","keys_url":"https://api.github.com/repos/Laliska/perun-services/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Laliska/perun-services/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Laliska/perun-services/teams","hooks_url":"https://api.github.com/repos/Laliska/perun-services/hooks","issue_events_url":"https://api.github.com/repos/Laliska/perun-services/issues/events{/number}","events_url":"https://api.github.com/repos/Laliska/perun-services/events","assignees_url":"https://api.github.com/repos/Laliska/perun-services/assignees{/user}","branches_url":"https://api.github.com/repos/Laliska/perun-services/branches{/branch}","tags_url":"https://api.github.com/repos/Laliska/perun-services/tags","blobs_url":"https://api.github.com/repos/Laliska/perun-services/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Laliska/perun-services/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Laliska/perun-services/git/refs{/sha}","trees_url":"https://api.github.com/repos/Laliska/perun-services/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Laliska/perun-services/statuses/{sha}","languages_url":"https://api.github.com/repos/Laliska/perun-services/languages","stargazers_url":"https://api.github.com/repos/Laliska/perun-services/stargazers","contributors_url":"https://api.github.com/repos/Laliska/perun-services/contributors","subscribers_url":"https://api.github.com/repos/Laliska/perun-services/subscribers","subscription_url":"https://api.github.com/repos/Laliska/perun-services/subscription","commits_url":"https://api.github.com/repos/Laliska/perun-services/commits{/sha}","git_commits_url":"https://api.github.com/repos/Laliska/perun-services/git/commits{/sha}","comments_url":"https://api.github.com/repos/Laliska/perun-services/comments{/number}","issue_comment_url":"https://api.github.com/repos/Laliska/perun-services/issues/comments{/number}","contents_url":"https://api.github.com/repos/Laliska/perun-services/contents/{+path}","compare_url":"https://api.github.com/repos/Laliska/perun-services/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Laliska/perun-services/merges","archive_url":"https://api.github.com/repos/Laliska/perun-services/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Laliska/perun-services/downloads","issues_url":"https://api.github.com/repos/Laliska/perun-services/issues{/number}","pulls_url":"https://api.github.com/repos/Laliska/perun-services/pulls{/number}","milestones_url":"https://api.github.com/repos/Laliska/perun-services/milestones{/number}","notifications_url":"https://api.github.com/repos/Laliska/perun-services/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Laliska/perun-services/labels{/name}","releases_url":"https://api.github.com/repos/Laliska/perun-services/releases{/id}","deployments_url":"https://api.github.com/repos/Laliska/perun-services/deployments","created_at":"2015-05-29T13:46:19Z","updated_at":"2016-01-23T17:09:44Z","pushed_at":"2016-09-06T13:53:55Z","git_url":"git://github.com/Laliska/perun-services.git","ssh_url":"git@github.com:Laliska/perun-services.git","clone_url":"https://github.com/Laliska/perun-services.git","svn_url":"https://github.com/Laliska/perun-services","homepage":null,"size":439,"stargazers_count":0,"watchers_count":0,"language":"Perl","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":"master"}},"base":{"label":"CESNET:master","ref":"master","sha":"ef3276879c516c7e7de23ec05909624087d2ee97","user":{"login":"CESNET","id":1116469,"avatar_url":"https://avatars.githubusercontent.com/u/1116469?v=3","gravatar_id":"","url":"https://api.github.com/users/CESNET","html_url":"https://github.com/CESNET","followers_url":"https://api.github.com/users/CESNET/followers","following_url":"https://api.github.com/users/CESNET/following{/other_user}","gists_url":"https://api.github.com/users/CESNET/gists{/gist_id}","starred_url":"https://api.github.com/users/CESNET/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESNET/subscriptions","organizations_url":"https://api.github.com/users/CESNET/orgs","repos_url":"https://api.github.com/users/CESNET/repos","events_url":"https://api.github.com/users/CESNET/events{/privacy}","received_events_url":"https://api.github.com/users/CESNET/received_events","type":"Organization","site_admin":false},"repo":{"id":36226500,"name":"perun-services","full_name":"CESNET/perun-services","owner":{"login":"CESNET","id":1116469,"avatar_url":"https://avatars.githubusercontent.com/u/1116469?v=3","gravatar_id":"","url":"https://api.github.com/users/CESNET","html_url":"https://github.com/CESNET","followers_url":"https://api.github.com/users/CESNET/followers","following_url":"https://api.github.com/users/CESNET/following{/other_user}","gists_url":"https://api.github.com/users/CESNET/gists{/gist_id}","starred_url":"https://api.github.com/users/CESNET/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESNET/subscriptions","organizations_url":"https://api.github.com/users/CESNET/orgs","repos_url":"https://api.github.com/users/CESNET/repos","events_url":"https://api.github.com/users/CESNET/events{/privacy}","received_events_url":"https://api.github.com/users/CESNET/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CESNET/perun-services","description":"","fork":false,"url":"https://api.github.com/repos/CESNET/perun-services","forks_url":"https://api.github.com/repos/CESNET/perun-services/forks","keys_url":"https://api.github.com/repos/CESNET/perun-services/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CESNET/perun-services/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CESNET/perun-services/teams","hooks_url":"https://api.github.com/repos/CESNET/perun-services/hooks","issue_events_url":"https://api.github.com/repos/CESNET/perun-services/issues/events{/number}","events_url":"https://api.github.com/repos/CESNET/perun-services/events","assignees_url":"https://api.github.com/repos/CESNET/perun-services/assignees{/user}","branches_url":"https://api.github.com/repos/CESNET/perun-services/branches{/branch}","tags_url":"https://api.github.com/repos/CESNET/perun-services/tags","blobs_url":"https://api.github.com/repos/CESNET/perun-services/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CESNET/perun-services/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CESNET/perun-services/git/refs{/sha}","trees_url":"https://api.github.com/repos/CESNET/perun-services/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CESNET/perun-services/statuses/{sha}","languages_url":"https://api.github.com/repos/CESNET/perun-services/languages","stargazers_url":"https://api.github.com/repos/CESNET/perun-services/stargazers","contributors_url":"https://api.github.com/repos/CESNET/perun-services/contributors","subscribers_url":"https://api.github.com/repos/CESNET/perun-services/subscribers","subscription_url":"https://api.github.com/repos/CESNET/perun-services/subscription","commits_url":"https://api.github.com/repos/CESNET/perun-services/commits{/sha}","git_commits_url":"https://api.github.com/repos/CESNET/perun-services/git/commits{/sha}","comments_url":"https://api.github.com/repos/CESNET/perun-services/comments{/number}","issue_comment_url":"https://api.github.com/repos/CESNET/perun-services/issues/comments{/number}","contents_url":"https://api.github.com/repos/CESNET/perun-services/contents/{+path}","compare_url":"https://api.github.com/repos/CESNET/perun-services/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CESNET/perun-services/merges","archive_url":"https://api.github.com/repos/CESNET/perun-services/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CESNET/perun-services/downloads","issues_url":"https://api.github.com/repos/CESNET/perun-services/issues{/number}","pulls_url":"https://api.github.com/repos/CESNET/perun-services/pulls{/number}","milestones_url":"https://api.github.com/repos/CESNET/perun-services/milestones{/number}","notifications_url":"https://api.github.com/repos/CESNET/perun-services/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CESNET/perun-services/labels{/name}","releases_url":"https://api.github.com/repos/CESNET/perun-services/releases{/id}","deployments_url":"https://api.github.com/repos/CESNET/perun-services/deployments","created_at":"2015-05-25T11:06:27Z","updated_at":"2016-09-06T07:20:09Z","pushed_at":"2016-09-08T06:13:22Z","git_url":"git://github.com/CESNET/perun-services.git","ssh_url":"git@github.com:CESNET/perun-services.git","clone_url":"https://github.com/CESNET/perun-services.git","svn_url":"https://github.com/CESNET/perun-services","homepage":null,"size":550,"stargazers_count":3,"watchers_count":3,"language":"Perl","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":14,"forks":15,"open_issues":14,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CESNET/perun-services/pulls/107"},"html":{"href":"https://github.com/CESNET/perun-services/pull/107"},"issue":{"href":"https://api.github.com/repos/CESNET/perun-services/issues/107"},"comments":{"href":"https://api.github.com/repos/CESNET/perun-services/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/CESNET/perun-services/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/CESNET/perun-services/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CESNET/perun-services/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/CESNET/perun-services/statuses/2a72274b41683d792516196680bb532cdaf44902"}}}}
{"actor":{"display_login":"licehammer"}}