Exemple #1
0
        /// <summary>
        /// Executes the integration account map create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.Metadata != null)
            {
                this.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            if (string.IsNullOrEmpty(this.MapDefinition))
            {
                this.MapDefinition = CmdletHelper.GetContentFromFile(this.TryResolvePath(this.MapFilePath));
            }

            this.ContentType = this.MapType.Equals("liquid", StringComparison.CurrentCultureIgnoreCase) ? "text/plain" : "application/xml";

            this.WriteObject(IntegrationAccountClient.CreateIntegrationAccountMap(this.ResourceGroupName, integrationAccount.Name, this.MapName,
                                                                                  new IntegrationAccountMap
            {
                ContentType = this.ContentType,
                Content     = this.MapDefinition,
                MapType     = this.MapType,
                Metadata    = this.Metadata
            }), true);
        }
Exemple #2
0
        /// <summary>
        /// Executes the integration account map create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.Metadata != null)
            {
                this.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            if (string.IsNullOrEmpty(this.MapDefinition))
            {
                this.MapDefinition = CmdletHelper.GetContentFromFile(this.TryResolvePath(this.MapFilePath));
            }

            this.WriteObject(IntegrationAccountClient.CreateIntegrationAccountMap(this.ResourceGroupName, integrationAccount.Name, this.MapName,
                                                                                  new IntegrationAccountMap
            {
                ContentType = this.ContentType,
                Content     = this.MapDefinition,
                MapType     = this.MapType,
                Metadata    = this.Metadata
            }), true);
        }
        /// <summary>
        /// Executes the get integration account batch configuration command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.ParameterSetName == ParameterSet.ByInputObject)
            {
                var parsedResourceId = new ResourceIdentifier(this.ParentObject.Id);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ResourceName;
            }
            else if (this.ParameterSetName == ParameterSet.ByResourceId)
            {
                var parsedResourceId = new ResourceIdentifier(this.ParentResourceId);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ResourceName;
            }

            if (string.IsNullOrEmpty(this.Name))
            {
                this.WriteObject(IntegrationAccountClient.ListIntegrationAccountBatchConfigurations(this.ResourceGroupName, this.ParentName), true);
            }
            else
            {
                this.WriteObject(IntegrationAccountClient.GetIntegrationAccountBatchConfiguration(this.ResourceGroupName, this.ParentName, this.Name));
            }
        }
        /// <summary>
        /// Executes the command to remove integration account batch configuration
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.ParameterSetName == ParameterSet.ByInputObject)
            {
                var parsedResourceId = new ResourceIdentifier(this.InputObject.Id);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ParentResource.Split('/')[1];
                this.Name = parsedResourceId.ResourceName;
            }
            else if (this.ParameterSetName == ParameterSet.ByResourceId)
            {
                var parsedResourceId = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ParentResource.Split('/')[1];
                this.Name = parsedResourceId.ResourceName;
            }

            if (this.ShouldProcess(this.Name, string.Format(CultureInfo.InvariantCulture, Resource.RemoveIntegrationAccountArtifactMessage, Resource.BatchConfiguration, this.Name, this.ResourceGroupName)))
            {
                IntegrationAccountClient.RemoveIntegrationAccountBatchConfiguration(this.ResourceGroupName, this.ParentName, this.Name);
                if (this.PassThru)
                {
                    this.WriteObject(true);
                }
            }
        }
        /// <summary>
        /// Executes the integration account update command
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            if (!string.IsNullOrEmpty(this.Location))
            {
                integrationAccount.Location = this.Location;
            }

            if (!string.IsNullOrEmpty(this.Sku))
            {
                integrationAccount.Sku = new IntegrationAccountSku
                {
                    Name = this.Sku,
                };
            }

            ConfirmAction(Force.IsPresent,
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceWarning,
                                        "Microsoft.Logic/integrationAccounts", this.Name),
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceMessage,
                                        "Microsoft.Logic/integrationAccounts", this.Name),
                          Name,
                          () =>
            {
                this.WriteObject(
                    IntegrationAccountClient.UpdateIntegrationAccount(this.ResourceGroupName, this.Name,
                                                                      integrationAccount), true);
            },
                          null);
        }
        /// <summary>
        /// Executes the integration account partner create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.Metadata != null)
            {
                this.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            this.WriteObject(
                IntegrationAccountClient.CreateIntegrationAccountPartner(this.ResourceGroupName, integrationAccount.Name,
                                                                         this.PartnerName,
                                                                         new IntegrationAccountPartner
            {
                PartnerType = (PartnerType)Enum.Parse(typeof(PartnerType), this.PartnerType),
                Content     = new PartnerContent
                {
                    B2b = new B2BPartnerContent
                    {
                        BusinessIdentities = CmdletHelper.ConvertToBusinessIdentityList(BusinessIdentities)
                    }
                },
                Metadata = this.Metadata
            }), true);
        }
Exemple #7
0
        /// <summary>
        /// Executes the integration account schema create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.Metadata != null)
            {
                this.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            if (string.IsNullOrEmpty(this.SchemaDefinition))
            {
                this.SchemaDefinition = CmdletHelper.GetContentFromFile(this.TryResolvePath(this.SchemaFilePath));
            }

            this.WriteObject(
                IntegrationAccountClient.CreateIntegrationAccountSchema(this.ResourceGroupName, integrationAccount.Name,
                                                                        this.SchemaName,
                                                                        new IntegrationAccountSchema
            {
                ContentType = this.contentType,
                SchemaType  = (SchemaType)Enum.Parse(typeof(SchemaType), this.schemaType),
                Content     = this.SchemaDefinition,
                Metadata    = this.Metadata
            }), true);
        }
        /// <summary>
        /// Executes the integration account agreement create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.Metadata != null)
            {
                this.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            var hostPartner = IntegrationAccountClient.GetIntegrationAccountPartner(this.ResourceGroupName, this.Name,
                                                                                    this.HostPartner);
            var guestPartner = IntegrationAccountClient.GetIntegrationAccountPartner(this.ResourceGroupName, this.Name,
                                                                                     this.GuestPartner);

            var hostIdentity =
                hostPartner.Content.B2b.BusinessIdentities.FirstOrDefault(
                    s => s.Qualifier == this.HostIdentityQualifier && s.Value == this.HostIdentityQualifierValue);

            if (hostIdentity == null)
            {
                throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                            Properties.Resource.InvalidQualifierSpecified, this.HostIdentityQualifier, this.HostPartner));
            }

            var guestIdentity =
                guestPartner.Content.B2b.BusinessIdentities.FirstOrDefault(
                    s => s.Qualifier == this.GuestIdentityQualifier && s.Value == this.GuestIdentityQualifierValue);

            if (guestIdentity == null)
            {
                throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                            Properties.Resource.InvalidQualifierSpecified, this.GuestIdentityQualifier, this.GuestPartner));
            }

            if (string.IsNullOrEmpty(this.AgreementContent))
            {
                this.AgreementContent =
                    CmdletHelper.GetStringContentFromFile(this.TryResolvePath(this.AgreementContentFilePath));
            }

            this.WriteObject(
                IntegrationAccountClient.CreateIntegrationAccountAgreement(this.ResourceGroupName, integrationAccount.Name,
                                                                           this.AgreementName,
                                                                           new IntegrationAccountAgreement
            {
                AgreementType = (AgreementType)Enum.Parse(typeof(AgreementType), this.AgreementType),
                HostIdentity  = hostIdentity,
                GuestIdentity = guestIdentity,
                GuestPartner  = this.GuestPartner,
                HostPartner   = this.HostPartner,
                Content       = CmdletHelper.ConvertToAgreementContent(this.AgreementContent),
                Metadata      = this.Metadata
            }), true);
        }
Exemple #9
0
 /// <summary>
 /// Executes the command to remove integration account map
 /// </summary>
 public override void ExecuteCmdlet()
 {
     base.ExecuteCmdlet();
     ConfirmAction(Force.IsPresent,
                   string.Format(CultureInfo.InvariantCulture, Properties.Resource.RemoveResourceWarning, "Microsoft.Logic/integrationAccounts/maps", this.Name),
                   string.Format(CultureInfo.InvariantCulture, Properties.Resource.RemoveResourceMessage, "Microsoft.Logic/integrationAccounts/maps", this.Name),
                   Name,
                   () => {
         IntegrationAccountClient.RemoveIntegrationAccountMap(this.ResourceGroupName, this.Name, this.MapName);
     });
 }
Exemple #10
0
 /// <summary>
 /// Executes the get integration account command
 /// </summary>
 public override void ExecuteCmdlet()
 {
     base.ExecuteCmdlet();
     if (string.IsNullOrEmpty(this.Name))
     {
         this.WriteObject(IntegrationAccountClient.ListIntegrationAccount(this.ResourceGroupName), true);
     }
     else
     {
         this.WriteObject(IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name), true);
     }
 }
        /// <summary>
        /// Executes the get integration account callback URL command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            this.WriteObject(
                IntegrationAccountClient.GetIntegrationAccountCallbackUrl(this.ResourceGroupName, this.Name,
                                                                          (NotAfter != null)
                        ? new ListCallbackUrlParameters
            {
                NotAfter = NotAfter
            }
                        : new ListCallbackUrlParameters()), true);
        }
        /// <summary>
        /// Executes the integration account map update command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            var integrationAccountMap = IntegrationAccountClient.GetIntegrationAccountMap(this.ResourceGroupName,
                                                                                          this.Name,
                                                                                          this.MapName);

            if (!string.IsNullOrEmpty(this.MapFilePath))
            {
                integrationAccountMap.Content = CmdletHelper.GetContentFromFile(this.TryResolvePath(this.MapFilePath));
            }

            if (!string.IsNullOrEmpty(this.MapDefinition))
            {
                integrationAccountMap.Content = this.MapDefinition;
                CmdletHelper.GetContentFromFile(this.TryResolvePath(this.MapFilePath));
            }

            if (!string.IsNullOrEmpty(this.ContentType))
            {
                integrationAccountMap.ContentType = this.contentType;
            }

            if (!string.IsNullOrEmpty(this.MapType))
            {
                integrationAccountMap.MapType = (MapType)Enum.Parse(typeof(MapType), this.MapType);
            }

            if (this.Metadata != null)
            {
                integrationAccountMap.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            ConfirmAction(Force.IsPresent,
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceWarning,
                                        "Microsoft.Logic/integrationAccounts/maps", this.Name),
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceMessage,
                                        "Microsoft.Logic/integrationAccounts/maps", this.Name),
                          Name,
                          () =>
            {
                this.WriteObject(
                    IntegrationAccountClient.UpdateIntegrationAccountMap(this.ResourceGroupName, this.Name,
                                                                         this.MapName,
                                                                         integrationAccountMap), true);
            },
                          null);
        }
Exemple #13
0
 /// <summary>
 /// Executes the command to remove integration account agreement
 /// </summary>
 public override void ExecuteCmdlet()
 {
     base.ExecuteCmdlet();
     this.ConfirmAction(
         processMessage: string.Format(CultureInfo.InvariantCulture, Properties.Resource.RemoveResourceMessage, "received control number", this.Name),
         target: Name,
         action: () => {
         IntegrationAccountClient.RemoveIntegrationAccountReceivedControlNumber(
             resourceGroupName: this.ResourceGroupName,
             integrationAccountName: this.Name,
             integrationAccountAgreementName: this.AgreementName,
             controlNumber: this.ControlNumberValue);
     });
 }
Exemple #14
0
        /// <summary>
        /// Executes the integration account certificate create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.Metadata != null)
            {
                this.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            string certificate = null;

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            if (!string.IsNullOrEmpty(this.PublicCertificateFilePath))
            {
                var certificateFilePath = this.TryResolvePath(this.PublicCertificateFilePath);

                if (!string.IsNullOrEmpty(certificateFilePath) && CmdletHelper.FileExists(certificateFilePath))
                {
                    var cert = new X509Certificate2(certificateFilePath);
                    certificate = Convert.ToBase64String(cert.RawData);
                }
            }

            KeyVaultKeyReference keyref = null;

            if (!string.IsNullOrEmpty(this.KeyName) && !string.IsNullOrEmpty(this.KeyVersion) && !string.IsNullOrEmpty(this.KeyVaultId))
            {
                keyref = new KeyVaultKeyReference
                {
                    KeyName    = this.KeyName,
                    KeyVersion = this.KeyVersion,
                    KeyVault   = new KeyVaultKeyReferenceKeyVault()
                    {
                        Id = this.KeyVaultId
                    }
                };
            }

            this.WriteObject(
                IntegrationAccountClient.CreateIntegrationAccountCertificate(this.ResourceGroupName,
                                                                             integrationAccount.Name,
                                                                             this.CertificateName, new IntegrationAccountCertificate
            {
                Key               = keyref,
                Metadata          = this.Metadata,
                PublicCertificate = certificate
            }
                                                                             ), true);
        }
Exemple #15
0
        /// <summary>
        /// Executes the integration account create command
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            this.WriteObject(
                IntegrationAccountClient.CreateIntegrationAccount(this.ResourceGroupName, this.Name, new IntegrationAccount
            {
                Location = this.Location,
                Sku      = new IntegrationAccountSku
                {
                    Name = this.Sku
                },
                Properties = new JObject()
            }), true);
        }
Exemple #16
0
        /// <summary>
        /// Executes the get integration account callback URL command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            this.WriteObject(
                sendToPipeline: IntegrationAccountClient.GetIntegrationAccountCallbackUrl(
                    resourceGroupName: this.ResourceGroupName,
                    integrationAccountName: this.Name,
                    callbackUrl: (NotAfter != null)
                        ? new GetCallbackUrlParameters
            {
                NotAfter = NotAfter
            }
                        : new GetCallbackUrlParameters()),
                enumerateCollection: true);
        }
Exemple #17
0
        /// <summary>
        /// Executes the integration account partner update command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            var integrationAccountPartner = IntegrationAccountClient.GetIntegrationAccountPartner(
                this.ResourceGroupName,
                this.Name, this.PartnerName);

            if (!string.IsNullOrEmpty(this.PartnerType))
            {
                integrationAccountPartner.PartnerType = (PartnerType)Enum.Parse(typeof(PartnerType), this.PartnerType);
            }

            if (this.BusinessIdentities != null)
            {
                integrationAccountPartner.Content.B2b.BusinessIdentities =
                    CmdletHelper.ConvertToBusinessIdentityList(this.BusinessIdentities);
            }

            if (this.Metadata != null)
            {
                integrationAccountPartner.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            ConfirmAction(Force.IsPresent,
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceWarning,
                                        "Microsoft.Logic/integrationAccounts/partners", this.Name),
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceMessage,
                                        "Microsoft.Logic/integrationAccounts/partners", this.Name),
                          Name,
                          () =>
            {
                this.WriteObject(
                    IntegrationAccountClient.UpdateIntegrationAccountPartner(this.ResourceGroupName,
                                                                             integrationAccount.Name,
                                                                             this.PartnerName,
                                                                             integrationAccountPartner), true);
            },
                          null);
        }
        /// <summary>
        /// Executes the command to remove integration account agreement
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (string.IsNullOrEmpty(AgreementType))
            {
                this.WriteWarning(Constants.NoAgreementTypeParameterWarningMessage);
                AgreementType = "X12";
            }

            this.ConfirmAction(
                processMessage: string.Format(CultureInfo.InvariantCulture, Properties.Resource.RemoveResourceMessage, "received control number", this.Name),
                target: Name,
                action: () => {
                IntegrationAccountClient.RemoveIntegrationAccountReceivedControlNumber(
                    resourceGroupName: this.ResourceGroupName,
                    integrationAccountName: this.Name,
                    integrationAccountAgreementName: this.AgreementName,
                    agreementType: (AgreementType)Enum.Parse(enumType: typeof(AgreementType), value: AgreementType, ignoreCase: true),
                    controlNumber: this.ControlNumberValue);
            });
        }
Exemple #19
0
        /// <summary>
        /// Executes the integration account certificate update command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            var integrationAccountCertificate =
                IntegrationAccountClient.GetIntegrationAccountCertifcate(this.ResourceGroupName,
                                                                         this.Name, this.CertificateName);

            if (!string.IsNullOrEmpty(this.KeyName))
            {
                integrationAccountCertificate.Key.KeyName = this.KeyName;
            }

            if (!string.IsNullOrEmpty(this.KeyVersion))
            {
                integrationAccountCertificate.Key.KeyVersion = this.KeyVersion;
            }

            if (!string.IsNullOrEmpty(this.KeyVaultId))
            {
                integrationAccountCertificate.Key.KeyVault.Id = this.KeyVaultId;
            }

            string certificate = null;

            if (!string.IsNullOrEmpty(this.PublicCertificateFilePath))
            {
                var certificateFilePath = this.TryResolvePath(this.PublicCertificateFilePath);

                if (!string.IsNullOrEmpty(certificateFilePath) && CmdletHelper.FileExists(certificateFilePath))
                {
                    var cert = new X509Certificate2(certificateFilePath);
                    certificate = Convert.ToBase64String(cert.RawData);
                }
            }

            if (!string.IsNullOrEmpty(certificate))
            {
                integrationAccountCertificate.PublicCertificate = certificate;
            }

            if (this.Metadata != null)
            {
                integrationAccountCertificate.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            ConfirmAction(Force.IsPresent,
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceWarning,
                                        "Microsoft.Logic/integrationAccounts/certificates", this.Name),
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceMessage,
                                        "Microsoft.Logic/integrationAccounts/certificates", this.Name),
                          Name,
                          () =>
            {
                this.WriteObject(
                    IntegrationAccountClient.UpdateIntegrationAccountCertificate(this.ResourceGroupName,
                                                                                 integrationAccount.Name,
                                                                                 this.CertificateName, integrationAccountCertificate), true);
            },
                          null);
        }
Exemple #20
0
        /// <summary>
        /// Executes the integration account agreement update command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var integrationAccountAgreement =
                IntegrationAccountClient.GetIntegrationAccountAgreement(this.ResourceGroupName,
                                                                        this.Name, this.AgreementName);

            if (this.Metadata != null)
            {
                integrationAccountAgreement.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            var hostPartner = IntegrationAccountClient.GetIntegrationAccountPartner(this.ResourceGroupName, this.Name,
                                                                                    string.IsNullOrEmpty(this.HostPartner)
                    ? integrationAccountAgreement.HostPartner
                    : this.HostPartner);

            integrationAccountAgreement.HostPartner = hostPartner.Name;

            var guestPartner = IntegrationAccountClient.GetIntegrationAccountPartner(this.ResourceGroupName, this.Name,
                                                                                     string.IsNullOrEmpty(this.GuestPartner)
                    ? integrationAccountAgreement.GuestPartner
                    : this.GuestPartner);

            integrationAccountAgreement.GuestPartner = guestPartner.Name;

            if (!string.IsNullOrEmpty(this.HostIdentityQualifier) && !string.IsNullOrEmpty(this.HostIdentityQualifierValue))
            {
                var hostIdentity =
                    hostPartner.Content.B2b.BusinessIdentities.FirstOrDefault(
                        s => (s.Qualifier == this.HostIdentityQualifier && s.Value == this.HostIdentityQualifierValue));

                if (hostIdentity == null)
                {
                    throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                                Properties.Resource.InvalidQualifierSpecified, this.HostIdentityQualifier, hostPartner.Name));
                }

                integrationAccountAgreement.HostIdentity = hostIdentity;
            }
            else if (string.IsNullOrEmpty(this.HostIdentityQualifier) ^ string.IsNullOrEmpty(this.HostIdentityQualifierValue))
            {
                throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resource.QualifierWithValueNotSpecified, "Host"));
            }

            if (!string.IsNullOrEmpty(this.GuestIdentityQualifier) && !string.IsNullOrEmpty(this.GuestIdentityQualifierValue))
            {
                var guestIdentity =
                    guestPartner.Content.B2b.BusinessIdentities.FirstOrDefault(
                        s => (s.Qualifier == this.GuestIdentityQualifier && s.Value == this.GuestIdentityQualifierValue));

                if (guestIdentity == null)
                {
                    throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                                Properties.Resource.InvalidQualifierSpecified, this.GuestIdentityQualifier, guestPartner.Name));
                }

                integrationAccountAgreement.GuestIdentity = guestIdentity;
            }
            else if (string.IsNullOrEmpty(this.GuestIdentityQualifier) ^ string.IsNullOrEmpty(this.GuestIdentityQualifierValue))
            {
                throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resource.QualifierWithValueNotSpecified, "Guest"));
            }

            if (!string.IsNullOrEmpty(this.AgreementType))
            {
                integrationAccountAgreement.AgreementType =
                    (AgreementType)Enum.Parse(typeof(AgreementType), this.AgreementType);
            }

            if (!string.IsNullOrEmpty(this.AgreementContentFilePath))
            {
                this.AgreementContent =
                    CmdletHelper.GetStringContentFromFile(this.TryResolvePath(this.AgreementContentFilePath));
            }

            if (!string.IsNullOrEmpty(this.AgreementContent))
            {
                integrationAccountAgreement.Content = CmdletHelper.ConvertToAgreementContent(this.AgreementContent);
            }

            ConfirmAction(Force.IsPresent,
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceWarning,
                                        "Microsoft.Logic/integrationAccounts/agreements", this.Name),
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceMessage,
                                        "Microsoft.Logic/integrationAccounts/agreements", this.Name),
                          Name,
                          () =>
            {
                this.WriteObject(
                    IntegrationAccountClient.UpdateIntegrationAccountAgreement(this.ResourceGroupName, this.Name,
                                                                               this.AgreementName,
                                                                               integrationAccountAgreement), true);
            },
                          null);
        }
        /// <summary>
        /// Executes the integration account batch configuration update command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            switch (this.ParameterSetName)
            {
            case ParameterSet.ByInputObjectAndJson:
            case ParameterSet.ByInputObjectAndFilePath:
            case ParameterSet.ByInputObjectAndParameters:
            {
                var parsedResourceId = new ResourceIdentifier(this.InputObject.Id);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ResourceName;
                break;
            }

            case ParameterSet.ByResourceIdAndJson:
            case ParameterSet.ByResourceIdAndFilePath:
            case ParameterSet.ByResourceIdAndParameters:
            {
                var parsedResourceId = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ResourceName;
                break;
            }
            }

            var batchConfiguration = new BatchConfiguration();

            switch (this.ParameterSetName)
            {
            case ParameterSet.ByInputObjectAndJson:
            case ParameterSet.ByResourceIdAndJson:
            case ParameterSet.ByIntegrationAccountAndJson:
            {
                batchConfiguration.Properties = CmdletHelper.ConvertToBatchConfigurationProperties(this.BatchConfigurationDefinition);
                break;
            }

            case ParameterSet.ByInputObjectAndFilePath:
            case ParameterSet.ByResourceIdAndFilePath:
            case ParameterSet.ByIntegrationAccountAndFilePath:
            {
                batchConfiguration.Properties = CmdletHelper.ConvertToBatchConfigurationProperties(CmdletHelper.GetStringContentFromFile(this.TryResolvePath(this.BatchConfigurationFilePath)));
                break;
            }

            case ParameterSet.ByInputObjectAndParameters:
            case ParameterSet.ByResourceIdAndParameters:
            case ParameterSet.ByIntegrationAccountAndParameters:
            {
                var releaseCriteria = new BatchReleaseCriteria();
                if (this.MyInvocation.BoundParameters.ContainsKey("MessageCount"))
                {
                    releaseCriteria.MessageCount = this.MessageCount;
                }

                if (this.MyInvocation.BoundParameters.ContainsKey("BatchSize"))
                {
                    releaseCriteria.BatchSize = this.BatchSize;
                }

                if (this.MyInvocation.BoundParameters.ContainsKey("ScheduleInterval"))
                {
                    releaseCriteria.Recurrence = new WorkflowTriggerRecurrence
                    {
                        Interval  = this.ScheduleInterval,
                        Frequency = this.ScheduleFrequency,
                        TimeZone  = !string.IsNullOrWhiteSpace(this.ScheduleTimeZone) ? this.ScheduleTimeZone : null,
                        StartTime = this.ScheduleStartTime?.ToShortDateString()
                    };
                }

                batchConfiguration.Properties = new BatchConfigurationProperties
                {
                    BatchGroupName  = this.BatchGroupName,
                    ReleaseCriteria = releaseCriteria
                };

                if (!this.IsValidReleaseCriteria(releaseCriteria))
                {
                    throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture, Resource.BatchConfigurationParameterNeedsToBeSpecified));
                }

                break;
            }
            }

            batchConfiguration.Properties.Metadata = this.Metadata;

            if (this.ShouldProcess(this.Name, string.Format(CultureInfo.InvariantCulture, Resource.UpdateIntegrationAccountArtifactMessage, Resource.BatchConfiguration, this.Name, this.ResourceGroupName)))
            {
                var updatedBatchConfiguration = IntegrationAccountClient.UpdateIntegrationAccountBatchConfiguration(this.ResourceGroupName, this.ParentName, this.Name, batchConfiguration);
                this.WriteObject(updatedBatchConfiguration);
            }
        }
Exemple #22
0
        /// <summary>
        /// Executes the integration account map update command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            var integrationAccountMap = IntegrationAccountClient.GetIntegrationAccountMap(this.ResourceGroupName,
                                                                                          this.Name,
                                                                                          this.MapName);

            var integrationAccountMapCopy = new IntegrationAccountMap(mapType: integrationAccountMap.MapType,
                                                                      id: integrationAccountMap.Id,
                                                                      name: integrationAccountMap.Name,
                                                                      type: integrationAccountMap.Type,
                                                                      location: integrationAccountMap.Location,
                                                                      tags: integrationAccountMap.Tags,
                                                                      parametersSchema: integrationAccountMap.ParametersSchema,
                                                                      createdTime: integrationAccountMap.CreatedTime,
                                                                      changedTime: integrationAccountMap.ChangedTime,
                                                                      content: integrationAccountMap.Content,
                                                                      contentLink: null,
                                                                      metadata: integrationAccountMap.Metadata);

            if (!string.IsNullOrEmpty(this.MapFilePath))
            {
                integrationAccountMapCopy.Content = CmdletHelper.GetStringContentFromFile(this.TryResolvePath(this.MapFilePath));
            }

            if (!string.IsNullOrEmpty(this.MapDefinition))
            {
                integrationAccountMapCopy.Content = this.MapDefinition;
                CmdletHelper.GetStringContentFromFile(this.TryResolvePath(this.MapFilePath));
            }

            if (!string.IsNullOrEmpty(this.MapType))
            {
                integrationAccountMapCopy.MapType = this.MapType;
            }

            integrationAccountMapCopy.ContentType = this.MapType.Equals("liquid", StringComparison.CurrentCultureIgnoreCase) ? "text/plain" : "application/xml";

            if (this.Metadata != null)
            {
                integrationAccountMapCopy.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            ConfirmAction(Force.IsPresent,
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceWarning,
                                        "Microsoft.Logic/integrationAccounts/maps", this.Name),
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceMessage,
                                        "Microsoft.Logic/integrationAccounts/maps", this.Name),
                          Name,
                          () =>
            {
                this.WriteObject(
                    IntegrationAccountClient.UpdateIntegrationAccountMap(this.ResourceGroupName, this.Name,
                                                                         this.MapName,
                                                                         integrationAccountMapCopy), true);
            },
                          null);
        }
Exemple #23
0
        /// <summary>
        /// Executes the integration account schema create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name);

            var integrationAccountSchema = IntegrationAccountClient.GetIntegrationAccountSchema(this.ResourceGroupName,
                                                                                                this.Name,
                                                                                                this.SchemaName);

            var integrationAccountSchemaCopy = new IntegrationAccountSchema(schemaType: integrationAccountSchema.SchemaType,
                                                                            id: integrationAccountSchema.Id,
                                                                            name: integrationAccountSchema.Name,
                                                                            type: integrationAccountSchema.Type,
                                                                            location: integrationAccountSchema.Location,
                                                                            tags: integrationAccountSchema.Tags,
                                                                            targetNamespace: integrationAccountSchema.TargetNamespace,
                                                                            documentName: integrationAccountSchema.DocumentName,
                                                                            fileName: integrationAccountSchema.FileName,
                                                                            createdTime: integrationAccountSchema.CreatedTime,
                                                                            changedTime: integrationAccountSchema.ChangedTime,
                                                                            metadata: integrationAccountSchema.Metadata,
                                                                            content: integrationAccountSchema.Content,
                                                                            contentType: integrationAccountSchema.ContentType,
                                                                            contentLink: null);

            if (!string.IsNullOrEmpty(this.SchemaFilePath))
            {
                integrationAccountSchemaCopy.Content =
                    CmdletHelper.GetContentFromFile(this.TryResolvePath(this.SchemaFilePath));
            }

            if (!string.IsNullOrEmpty(this.SchemaDefinition))
            {
                integrationAccountSchemaCopy.Content = this.SchemaDefinition;
            }

            if (!string.IsNullOrEmpty(this.schemaType))
            {
                integrationAccountSchemaCopy.SchemaType = (SchemaType)Enum.Parse(typeof(SchemaType), this.SchemaType);
            }

            if (!string.IsNullOrEmpty(this.ContentType))
            {
                integrationAccountSchemaCopy.ContentType = this.ContentType;
            }

            if (this.Metadata != null)
            {
                integrationAccountSchemaCopy.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata);
            }

            ConfirmAction(Force.IsPresent,
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceWarning,
                                        "Microsoft.Logic/integrationAccounts/schemas", this.Name),
                          string.Format(CultureInfo.InvariantCulture, Properties.Resource.UpdateResourceMessage,
                                        "Microsoft.Logic/integrationAccounts/schemas", this.Name),
                          Name,
                          () =>
            {
                this.WriteObject(
                    IntegrationAccountClient.UpdateIntegrationAccountSchema(this.ResourceGroupName,
                                                                            integrationAccount.Name,
                                                                            this.SchemaName, integrationAccountSchemaCopy), true);
            },
                          null);
        }
        /// <summary>
        /// Executes the integration account assembly create command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            switch (this.ParameterSetName)
            {
            case ParameterSet.ByInputObjectAndContentLink:
            case ParameterSet.ByInputObjectAndFileBytes:
            case ParameterSet.ByInputObjectAndFilePath:
            {
                var parsedResourceId = new ResourceIdentifier(this.ParentObject.Id);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ResourceName;
                break;
            }

            case ParameterSet.ByResourceIdAndContentLink:
            case ParameterSet.ByResourceIdAndFileBytes:
            case ParameterSet.ByResourceIdAndFilePath:
            {
                var parsedResourceId = new ResourceIdentifier(this.ParentResourceId);
                this.ResourceGroupName = parsedResourceId.ResourceGroupName;
                this.ParentName        = parsedResourceId.ParentResource.Split('/')[1];
                break;
            }
            }

            var assemblyDefinition = new AssemblyDefinition
            {
                Properties = new AssemblyProperties
                {
                    AssemblyName = this.Name,
                    ContentType  = "application/octet-stream",
                    Metadata     = this.Metadata
                }
            };

            switch (this.ParameterSetName)
            {
            case ParameterSet.ByInputObjectAndContentLink:
            case ParameterSet.ByResourceIdAndContentLink:
            case ParameterSet.ByIntegrationAccountAndContentLink:
            {
                assemblyDefinition.Properties.ContentLink = new ContentLink
                {
                    Uri = this.ContentLink
                };
                assemblyDefinition.Properties.Content = null;
                break;
            }

            case ParameterSet.ByInputObjectAndFileBytes:
            case ParameterSet.ByResourceIdAndFileBytes:
            case ParameterSet.ByIntegrationAccountAndFileBytes:
            {
                assemblyDefinition.Properties.Content     = this.AssemblyData;
                assemblyDefinition.Properties.ContentLink = null;
                break;
            }

            case ParameterSet.ByInputObjectAndFilePath:
            case ParameterSet.ByResourceIdAndFilePath:
            case ParameterSet.ByIntegrationAccountAndFilePath:
            {
                assemblyDefinition.Properties.Content     = CmdletHelper.GetBinaryContentFromFile(this.TryResolvePath(this.AssemblyFilePath));
                assemblyDefinition.Properties.ContentLink = null;
                break;
            }
            }

            if (this.ShouldProcess(this.Name, string.Format(CultureInfo.InvariantCulture, Resource.CreateIntegrationAccountArtifactMessage, Resource.Assembly, this.Name, this.ResourceGroupName)))
            {
                this.WriteObject(IntegrationAccountClient.CreateIntegrationAccountAssembly(this.ResourceGroupName, this.ParentName, this.Name, assemblyDefinition));
            }
        }