コード例 #1
0
        /// <summary>
        /// Validates parameter input before processing the pipeline.
        /// </summary>
        /// <remarks>
        /// This method gets called once for each cmdlet in the pipeline when the pipeline starts executing (before the process block of any other command).
        /// </remarks>
        protected override void BeginProcessing()
        {
            if (!PoshBoxAuth.IsInitialized)
            {
                ThrowTerminatingError(
                    new ErrorRecord(
                        new Exception("No Box configuration found. Use Connect-Box to import a configuration."),
                        "9000",
                        ErrorCategory.InvalidOperation,
                        null
                        ));
            }

            if (Array.Exists(Properties, name => name == "*"))
            {
                Properties = BoxItemPropertyNameCompleter.AllPropertyNames;
            }

            fieldNames = PropertyUtility.GetPropertyNames(typeof(BoxItem), Properties);

            if (UserID == null)
            {
                WriteVerbose("Using admin client already established: " + PoshBoxAuth.BoxConfiguration.ClientId);
                client = PoshBoxAuth.BoxClient;
            }
            else
            {
                WriteVerbose("Retrieving user client for user: "******"WebLink") ? "web_link" : ItemType?.ToLower();
            Scope    = (Scope == "UserContent") ? "user_content" : "enterprise_content";
            Sort     = (Sort == "Relevance") ? "relevance" : "modified_at";
        }
コード例 #2
0
        /// <summary>
        /// Validates parameter input before processing the pipeline.
        /// </summary>
        /// <remarks>
        /// This method gets called once for each cmdlet in the pipeline when the pipeline starts executing (before the process block of any other command).
        /// </remarks>
        protected override void BeginProcessing()
        {
            if (!PoshBoxAuth.IsInitialized)
            {
                ThrowTerminatingError(
                    new ErrorRecord(
                        new Exception("No Box configuration found. Use Connect-Box to import a configuration."),
                        "9000",
                        ErrorCategory.InvalidOperation,
                        null
                        ));
            }

            if (Array.Exists(Properties, name => name == "*"))
            {
                Properties = BoxCollaborationPropertyNameCompleter.AllPropertyNames;
            }

            fieldNames = PropertyUtility.GetPropertyNames(typeof(BoxCollaboration), Properties);

            if (UserID == null)
            {
                WriteVerbose("Using admin client already established: " + PoshBoxAuth.BoxConfiguration.ClientId);
                client = PoshBoxAuth.BoxClient;
            }
            else
            {
                WriteVerbose("Retrieving user client for user: " + UserID);
                client = PoshBoxAuth.NewUserClient(UserID);
            }
        }
コード例 #3
0
 // This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called.
 protected override void ProcessRecord()
 {
     if (String.IsNullOrEmpty(UserID))
     {
         WriteObject(PoshBoxAuth.BoxClient);
     }
     else
     {
         WriteObject(PoshBoxAuth.NewUserClient(UserID));
     }
 }
コード例 #4
0
        protected override void BeginProcessing()
        {
            if (PoshBoxAuth.IsInitialized && !Force)
            {
                WriteVerbose("Box configuration already imported. Use -Force to force a new configuration.");
                return;
            }

            WriteVerbose("Authenticating with configuration file: " + ConfigPath);

            PoshBoxAuth.LoadJWTAuthConfig(ConfigPath);
        }