UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

61 lines 2.92 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _EntraAdministrativeUnitAddCommand_instances, _EntraAdministrativeUnitAddCommand_initTelemetry, _EntraAdministrativeUnitAddCommand_initOptions; import request from "../../../../request.js"; import GraphCommand from "../../../base/GraphCommand.js"; import commands from "../../commands.js"; class EntraAdministrativeUnitAddCommand extends GraphCommand { get name() { return commands.ADMINISTRATIVEUNIT_ADD; } get description() { return 'Creates an administrative unit'; } constructor() { super(); _EntraAdministrativeUnitAddCommand_instances.add(this); __classPrivateFieldGet(this, _EntraAdministrativeUnitAddCommand_instances, "m", _EntraAdministrativeUnitAddCommand_initTelemetry).call(this); __classPrivateFieldGet(this, _EntraAdministrativeUnitAddCommand_instances, "m", _EntraAdministrativeUnitAddCommand_initOptions).call(this); } async commandAction(logger, args) { const requestOptions = { url: `${this.resource}/v1.0/directory/administrativeUnits`, headers: { accept: 'application/json;odata.metadata=none' }, responseType: 'json', data: { description: args.options.description, displayName: args.options.displayName, visibility: args.options.hiddenMembership ? 'HiddenMembership' : null } }; try { const administrativeUnit = await request.post(requestOptions); await logger.log(administrativeUnit); } catch (err) { this.handleRejectedODataJsonPromise(err); } } } _EntraAdministrativeUnitAddCommand_instances = new WeakSet(), _EntraAdministrativeUnitAddCommand_initTelemetry = function _EntraAdministrativeUnitAddCommand_initTelemetry() { this.telemetry.push((args) => { Object.assign(this.telemetryProperties, { hiddenMembership: !!args.options.hiddenMembership }); }); }, _EntraAdministrativeUnitAddCommand_initOptions = function _EntraAdministrativeUnitAddCommand_initOptions() { this.options.unshift({ option: '-n, --displayName <displayName>' }, { option: '-d, --description [description]' }, { option: '--hiddenMembership' }); }; export default new EntraAdministrativeUnitAddCommand(); //# sourceMappingURL=administrativeunit-add.js.map