Inheritance: TentacleEndpointResource
 public MachineResource ModifyMachine(MachineResource machine, string thumbprint, string hostname, int port, IEnumerable<string> environmentNames, IEnumerable<string> roles)
 {            
     machine.EnvironmentIds.Clear();    
     var environments = Repository.Environments.FindByNames(environmentNames);
     foreach (var environment in environments)
     {                
         machine.EnvironmentIds.Add(environment.Id);
     }
    
     machine.Roles.Clear();
     foreach (var role in roles)
     {
         machine.Roles.Add(role);
     }
     
     var endpoint = new ListeningTentacleEndpointResource();
     endpoint.Uri = $"https://{hostname}:{port}";
     endpoint.Thumbprint = thumbprint;
     machine.Endpoint = endpoint;
                 
     return Repository.Machines.Modify(machine);
 }
        void ApplyChanges(MachineResource machine, IEnumerable<EnvironmentResource> environment, MachinePolicyResource machinePolicy, IEnumerable<TenantResource> tenants)
        {
            machine.EnvironmentIds = new ReferenceCollection(environment.Select(e => e.Id).ToArray());
            machine.TenantIds = new ReferenceCollection(tenants.Select(t => t.Id).ToArray());
            machine.TenantTags = new ReferenceCollection(TenantTags);
            machine.Roles = new ReferenceCollection(Roles);
            machine.Name = MachineName;
            machine.MachinePolicyId = machinePolicy?.Id;

            if (CommunicationStyle == CommunicationStyle.TentaclePassive)
            {
                var listening = new ListeningTentacleEndpointResource();
                listening.Uri = new Uri("https://" + TentacleHostname.ToLowerInvariant() + ":" + TentaclePort.ToString(CultureInfo.InvariantCulture) + "/").ToString();
                listening.Thumbprint = TentacleThumbprint;
                machine.Endpoint = listening;
            }
            else if (CommunicationStyle == CommunicationStyle.TentacleActive)
            {
                var polling = new PollingTentacleEndpointResource();
                polling.Uri = SubscriptionId.ToString();
                polling.Thumbprint = TentacleThumbprint;
                machine.Endpoint = polling;
            }
        }