Exemplo n.º 1
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);
        }
Exemplo n.º 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.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);
        }
        /// <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);
        }
Exemplo n.º 5
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 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);
        }
Exemplo n.º 7
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 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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }