public override void ExecuteCmdlet()
        {
            var sac = StorageAccountCredentialsOperationsExtensions.Get(
                this.DataBoxEdgeManagementClient.StorageAccountCredentials,
                this.DeviceName,
                this.StorageAccountCredentialName,
                this.ResourceGroupName);

            _share = InitShareObject();

            if (this.IsParameterBound(c => c.ClientAccessRight))
            {
                _share.ClientAccessRights = new List <ClientAccessRight>();
                foreach (var clientAccessRight in this.ClientAccessRight)
                {
                    var accessRightPolicy = HashtableToDictionary <string, string>(clientAccessRight);
                    _share.ClientAccessRights.Add(
                        new ClientAccessRight(
                            accessRightPolicy.GetOrNull("ClientId"),
                            accessRightPolicy.GetOrNull("AccessRight")
                            )
                        );
                }
            }

            if (this.IsParameterBound(c => c.UserAccessRight))
            {
                _share.UserAccessRights = new List <UserAccessRight>();
                foreach (var userAccessRight in this.UserAccessRight)
                {
                    var accessRightPolicy = HashtableToDictionary <string, string>(userAccessRight);

                    _share.UserAccessRights.Add(
                        new UserAccessRight(
                            GetUserId(accessRightPolicy.GetOrNull("Username")),
                            accessRightPolicy.GetOrNull("AccessRight")
                            ));
                }
            }

            _share.AzureContainerInfo = new AzureContainerInfo(sac.Id, this.Name, this.DataFormat);
            if (this.ShouldProcess(this.Name,
                                   string.Format("Creating '{0}' in device '{1}' with name '{2}'.",
                                                 HelpMessageShare.ObjectName, this.DeviceName, this.Name)))
            {
                DoesResourceExists();
                var results = new List <PSResourceModel>()
                {
                    CreateResourceModel()
                };

                WriteObject(results, true);
            }
        }
        private ResourceModel AddAzureContainer(ResourceModel resourceModel)
        {
            var storageAccountCredential = this.DataBoxEdgeManagementClient.StorageAccountCredentials.Get(
                this.DeviceName,
                this.StorageAccountCredentialName,
                this.ResourceGroupName);

            resourceModel.AzureContainerInfo = this.IsParameterBound(c => c.ContainerName)
                ? new AzureContainerInfo(storageAccountCredential.Id, ContainerName, DataFormat)
                : new AzureContainerInfo(storageAccountCredential.Id, Name, this.DataFormat);
            return(resourceModel);
        }
        public override void ExecuteCmdlet()
        {
            _share = InitShareObject();

            if (this.IsParameterBound(c => c.ClientAccessRight))
            {
                _share.ClientAccessRights = new List <ClientAccessRight>();
                foreach (var clientAccessRight in this.ClientAccessRight)
                {
                    var accessRightPolicy = HashtableToDictionary <string, string>(clientAccessRight);
                    _share.ClientAccessRights.Add(
                        new ClientAccessRight(
                            accessRightPolicy.GetOrNull("ClientId"),
                            accessRightPolicy.GetOrNull("AccessRight")
                            )
                        );
                }
            }

            if (this.IsParameterBound(c => c.UserAccessRight))
            {
                _share.UserAccessRights = new List <UserAccessRight>();
                foreach (var userAccessRight in this.UserAccessRight)
                {
                    var accessRightPolicy = HashtableToDictionary <string, string>(userAccessRight);

                    _share.UserAccessRights.Add(
                        new UserAccessRight(
                            GetUserId(accessRightPolicy.GetOrNull("Username")),
                            accessRightPolicy.GetOrNull("AccessRight")
                            ));
                }
            }

            if (this.ShouldProcess(this.Name,
                                   string.Format("Creating '{0}' in device '{1}' with name '{2}'.",
                                                 HelpMessageShare.ObjectName, this.DeviceName, this.Name)))
            {
                DoesResourceExists();
                var results = new List <PSResourceModel>()
                {
                    CreateResourceModel()
                };

                WriteObject(results, true);
            }
        }
        private ResourceModel InitShareObject()
        {
            var dataPolicy = "Local";

            if (this.IsParameterBound(c => c.StorageAccountCredentialName))
            {
                dataPolicy = "Cloud";
            }

            var accessProtocol = this.NFS.IsPresent ? "NFS" : "SMB";
            var share          = new ResourceModel("Online",
                                                   "Enabled",
                                                   accessProtocol,
                                                   null, dataPolicy: dataPolicy);

            share = dataPolicy == "Cloud" ? AddAzureContainer(share) : share;
            return(share);
        }