I solved it, posting the solution below:
To set a file "sharable" you must set permissions in this api call in this way:
var resource = {
'value': 'default',
'type': 'anyone',
'role': 'reader'
};
var request = gapi.client.drive.permissions.insert({
'fileId': fileId,
'resource': resource
}).execute(function() {
alert("file set to public")
});
to set the file back to private there is update and delete method. In case of "delete", this is the way to perform it:
var request = gapi.client.drive.permissions.delete({
'fileId': fileId,
'permissionId': 'anyone'
}).execute(function() {
alert("public permissions revoked")
});