private IPage <ResourceModel> ListResourceModel(string nextPageLink)
 {
     return(SharesOperationsExtensions.ListByDataBoxEdgeDeviceNext(
                this.DataBoxEdgeManagementClient.Shares,
                nextPageLink
                ));
 }
 private IPage <ResourceModel> ListResourceModel()
 {
     return(SharesOperationsExtensions.ListByDataBoxEdgeDevice(
                this.DataBoxEdgeManagementClient.Shares,
                this.DeviceName,
                this.ResourceGroupName));
 }
 private ResourceModel GetResourceModel()
 {
     return(SharesOperationsExtensions.Get(
                this.DataBoxEdgeManagementClient.Shares,
                this.DeviceName,
                this.Name,
                this.ResourceGroupName));
 }
 private PSResourceModel CreateResourceModel()
 {
     return(new PSResourceModel(SharesOperationsExtensions.CreateOrUpdate(
                                    DataBoxEdgeManagementClient.Shares,
                                    this.DeviceName,
                                    this.Name,
                                    _share,
                                    this.ResourceGroupName)));
 }
Beispiel #5
0
        private bool Remove()
        {
            SharesOperationsExtensions.Delete(
                this.DataBoxEdgeManagementClient.Shares,
                this.DeviceName,
                this.Name,
                this.ResourceGroupName);

            return(true);
        }
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.InputObject))
            {
                this.DeviceName        = this.InputObject.DeviceName;
                this.Name              = this.InputObject.Name;
                this.ResourceGroupName = this.InputObject.ResourceGroupName;
            }

            if (this.IsParameterBound(c => c.ResourceId))
            {
                var resource = new DataBoxEdgeResourceIdentifier(this.ResourceId);
                this.DeviceName        = resource.DeviceName;
                this.ResourceGroupName = resource.ResourceGroupName;
                this.Name = resource.Name;
            }

            var share = this.GetResourceModel();

            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("Updating '{0}' in device '{1}' with name '{2}'.",
                                                 HelpMessageShare.ObjectName, this.DeviceName, this.Name)))
            {
                share = SharesOperationsExtensions.CreateOrUpdate(
                    DataBoxEdgeManagementClient.Shares,
                    this.DeviceName,
                    this.Name,
                    share,
                    this.ResourceGroupName);
                var results = new List <PSResourceModel>()
                {
                    new PSResourceModel(share)
                };
                WriteObject(results, true);
            }
        }