Exemple #1
0
        public override void ExecuteApiManagementCmdlet()
        {
            string resourceGroupName;
            string serviceName;
            string schemaId;
            string apiId;

            if (ParameterSetName.Equals(ContextParameterSet))
            {
                resourceGroupName = Context.ResourceGroupName;
                serviceName       = Context.ServiceName;
                schemaId          = SchemaId;
                apiId             = ApiId;
            }
            else
            {
                var diagnostic = new PsApiManagementApiSchema(ResourceId);
                resourceGroupName = diagnostic.ResourceGroupName;
                serviceName       = diagnostic.ServiceName;
                schemaId          = diagnostic.SchemaId;
                apiId             = diagnostic.ApiId;
            }

            if (string.IsNullOrEmpty(schemaId))
            {
                var apiSchemas = Client.ApiSchemaList(resourceGroupName, serviceName, apiId);
                WriteObject(apiSchemas, true);
            }
            else
            {
                var apiSchema = Client.ApiSchemaById(resourceGroupName, serviceName, apiId, schemaId);
                WriteObject(apiSchema);
            }
        }
Exemple #2
0
        public override void ExecuteApiManagementCmdlet()
        {
            string resourcegroupName;
            string serviceName;
            string apiId;
            string schemaId;

            if (ParameterSetName.Equals(ByInputObjectParameterSet))
            {
                resourcegroupName = InputObject.ResourceGroupName;
                serviceName       = InputObject.ServiceName;
                apiId             = InputObject.ApiId;
                schemaId          = InputObject.SchemaId;
            }
            else if (ParameterSetName.Equals(ExpandedParameterSet))
            {
                resourcegroupName = Context.ResourceGroupName;
                serviceName       = Context.ServiceName;
                apiId             = ApiId;
                schemaId          = SchemaId;
            }
            else
            {
                var psApiSchema = new PsApiManagementApiSchema(ResourceId);
                resourcegroupName = psApiSchema.ResourceGroupName;
                serviceName       = psApiSchema.ServiceName;
                apiId             = psApiSchema.ApiId;
                schemaId          = psApiSchema.SchemaId;
            }

            if (ShouldProcess(schemaId, Resources.SetApiSchema))
            {
                string schemaDocument = null;
                if (!string.IsNullOrWhiteSpace(SchemaDocument))
                {
                    schemaDocument = SchemaDocument;
                }
                else if (!string.IsNullOrEmpty(SchemaDocumentFilePath))
                {
                    schemaDocument = File.ReadAllText(SchemaDocumentFilePath);
                }

                var apiSchema = Client.ApiSchemaSet(
                    resourcegroupName,
                    serviceName,
                    apiId,
                    schemaId,
                    SchemaDocumentContentType,
                    schemaDocument,
                    InputObject);

                if (PassThru.IsPresent)
                {
                    WriteObject(apiSchema);
                }
            }
        }
        public override void ExecuteApiManagementCmdlet()
        {
            string resourceGroupName;
            string serviceName;
            string apiId;
            string schemaId;

            if (ParameterSetName.Equals(ByInputObjectParameterSet))
            {
                apiId             = InputObject.ApiId;
                schemaId          = InputObject.SchemaId;
                resourceGroupName = InputObject.ResourceGroupName;
                serviceName       = InputObject.ServiceName;
            }
            else if (ParameterSetName.Equals(ByApiSchemaIdParameterSet))
            {
                apiId             = ApiId;
                schemaId          = SchemaId;
                resourceGroupName = Context.ResourceGroupName;
                serviceName       = Context.ServiceName;
            }
            else
            {
                var apiSchema = new PsApiManagementApiSchema(ResourceId);
                resourceGroupName = apiSchema.ResourceGroupName;
                serviceName       = apiSchema.ServiceName;
                apiId             = apiSchema.ApiId;
                schemaId          = apiSchema.SchemaId;
            }

            var actionDescription = string.Format(CultureInfo.CurrentCulture, Resources.ApiSchemaRemoveDescription, schemaId, apiId);
            var actionWarning     = string.Format(CultureInfo.CurrentCulture, Resources.ApiSchemaRemoveWarning, schemaId, apiId);

            // Do nothing if force is not specified and user cancelled the operation
            if (!ShouldProcess(
                    actionDescription,
                    actionWarning,
                    Resources.ShouldProcessCaption))
            {
                return;
            }

            Client.ApiSchemaRemove(resourceGroupName, serviceName, apiId, schemaId);

            if (PassThru.IsPresent)
            {
                WriteObject(true);
            }
        }