Пример #1
0
 /// <summary>
 ///     The inherited Execute function.
 /// </summary>
 public override void Execute()
 {
     base.Execute();
     if (HelperExtensionMethods.IsValidEmail(this.Email))
     {
         this.WriteObject(new PSContactDetail(this.Role, this.Email, this.Phone));
     }
 }
Пример #2
0
        /// <summary>
        /// The create direct peering.
        /// </summary>
        /// <returns>
        /// The <see cref="PSPeering"/>.
        /// </returns>
        /// <exception cref="PSArgumentNullException">
        /// </exception>
        /// <exception cref="PSArgumentException">
        /// </exception>
        /// <exception cref="Exception">
        /// </exception>
        /// <exception cref="ArmErrorException">
        /// </exception>
        /// <exception cref="HttpRequestException">
        /// </exception>
        private PSPeerAsn CreatePeerInfo()
        {
            foreach (var s in Email)
            {
                HelperExtensionMethods.IsValidEmail(s);
            }

            var contactInfo = new PSContactInfo(emails: this.Email, phone: this.Phone);
            var peerInfo    = new PSPeerAsn(
                peerAsnProperty: this.PeerAsn,
                peerContactInfo: contactInfo,
                peerName: this.PeerName,
                name: this.Name);

            return(this.PutPeerInfo(peerInfo));
        }
        /// <summary>
        /// The update peer contact info.
        /// </summary>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        private object UpdatePeerContactInfo()
        {
            // Get old and verify its the same
            var oldPeerAsn = this.PeeringManagementClient.PeerAsns.Get(this.InputObject.Name);

            if (oldPeerAsn.Name == this.InputObject.Name &&
                oldPeerAsn.PeerAsnProperty == this.InputObject.PeerAsnProperty &&
                oldPeerAsn.PeerName == this.InputObject.PeerName)
            {
                var update = this.InputObject;
                if (this.Email != null)
                {
                    foreach (var email in this.Email)
                    {
                        if (HelperExtensionMethods.IsValidEmail(email))
                        {
                            update.PeerContactInfo.Emails.Add(email);
                        }
                    }
                }

                if (this.Phone == null)
                {
                    return(this.PeeringManagementClient.PeerAsns.CreateOrUpdate(
                               oldPeerAsn.Name,
                               this.ToPeeringAsn(update)));
                }
                foreach (var s in this.Phone)
                {
                    update.PeerContactInfo.Phone.Add(s);
                }

                return(this.PeeringManagementClient.PeerAsns.CreateOrUpdate(oldPeerAsn.Name, this.ToPeeringAsn(update)));
            }

            throw new Exception($"Only contact information can be changed");
        }