protected override void BeginProcessing() { try { var locationApi = new LocationApi(Utilities.Configuration); if (!string.IsNullOrEmpty(this.LocationId)) { if (!string.IsNullOrEmpty(LocationId)) { var location = locationApi.FindById(LocationId, depth: 5); WriteObject(location); } else { WriteWarning("Location Id must consist of region name and location name separated by '/' for example us/las "); } } else { var locations = locationApi.FindAll(depth: 5); WriteObject(locations.Items); } } catch (Exception ex) { WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null)); } }
protected override void BeginProcessing() { try { var dcApi = new LocationApi(new Configuration { Username = Credential.UserName, Password = Utilities.SecureStringToString(Credential.Password), UsedBy = Version.Get }); var dcs = dcApi.FindAll(depth: 5); Utilities.Configuration = new Configuration { Username = Credential.UserName, Password = Utilities.SecureStringToString(Credential.Password), UsedBy = Version.Get }; WriteObject("Authorization successful"); } catch (ApiException ex) { WriteError(new ErrorRecord(new Exception("Authentication failed"), ex.ErrorCode.ToString(), ErrorCategory.AuthenticationError, null)); } }