UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

68 lines (66 loc) 2.61 kB
import { throwError } from 'rxjs'; import { catchError, map, switchMap } from 'rxjs/operators'; /** * PowerShell Language mode values. * https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.pslanguagemode?view=powershellsdk-7.0.0 */ export var PSLanguageMode; (function (PSLanguageMode) { PSLanguageMode[PSLanguageMode["FullLanguage"] = 0] = "FullLanguage"; PSLanguageMode[PSLanguageMode["RestrictedLanguage"] = 1] = "RestrictedLanguage"; PSLanguageMode[PSLanguageMode["NoLanguage"] = 2] = "NoLanguage"; PSLanguageMode[PSLanguageMode["ConstrainedLanguage"] = 3] = "ConstrainedLanguage"; })(PSLanguageMode || (PSLanguageMode = {})); /** * Windows Defender Application Control (WDAC) Constants. */ export class WdacConstants { /** * PowerShell Language mode API endpoint. */ static psLanguageModeUrl = 'features/wdac/operations/psLanguageMode'; /** * Wdac cache reset API endpoint. */ static resetWdacCacheUrl = 'features/wdac/operations/resetWdacCache'; } /** * Windows Defender Application Control (WDAC) operations class. */ export class WdacOperations { appContext; /** * Initializes a new instance of the WdacOperations class. * * @param appContext the application context. */ constructor(appContext) { this.appContext = appContext; } /** * Gets the PowerShell Language Mode of a specified targetNodeName. * @param targetNodeName the machine name to get the WdacMode for. * @param options the NodeRequestOptions for this API call. */ getPsLanguageMode(targetNodeName, options) { return this.appContext.node.get(targetNodeName, WdacConstants.psLanguageModeUrl, options) .pipe(catchError((error, caught) => { // catch elevation error and retry after elevated. if (this.appContext.gateway.isElevationRequired(error)) { return this.appContext.gateway.pollingGatewayElevated() .pipe(switchMap(elevated => elevated ? caught : throwError(() => error))); } return throwError(() => error); })); } /** * Resets the WDAC cache of a specified targetNodeName. * @param targetNodeName the machine name to reset the WDAC cache for. * @param options the NodeRequestOptions for this API call. */ resetWdacCache(targetNodeName, options) { return this.appContext.node.post(targetNodeName, WdacConstants.resetWdacCacheUrl, null, options) .pipe(map(() => null)); } } //# sourceMappingURL=wdac-operations.js.map