Exemplo n.º 1
0
        public static SchemaInfo Schema(IBMWIoTP.ApiClient cli)
        {
            Console.WriteLine("Get all draft schima");
            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.GetAllDraftSchemas()));
            Console.WriteLine("===============================================================================");
            SchemaDraft sd = new SchemaDraft();

            sd.name       = "test";
            sd.schemaFile = "tempSchemaPi.json";
            Console.WriteLine("Add schima draft");
            SchemaInfo si = cli.AddDraftSchema(sd);

            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(si));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Updated draft schema content");
            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.UpdateDraftSchemaContent(si.id, "tempSchema.json")));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Delete draft schema");
            cli.DeleteDraftSchema(cli.AddDraftSchema(sd).id);
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Updated draft schema metadata");
            si.description = "new temp change";
            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.UpdateDraftSchemaMetadata(si)));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Get draft schima metadata");
            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.GetDraftSchemaMetadata(si.id)));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Get draft schima Content");
            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.GetDraftSchemaContent(si.id)));
            Console.WriteLine("===============================================================================");

            Console.WriteLine("Get All active schimas");
            SchemaCollection coll = cli.GetAllActiveSchemas();

            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(coll));
            Console.WriteLine("===============================================================================");
            if (coll.results.Length > 0)
            {
                Console.WriteLine("Get active schimas");
                Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.GetActiveSchemaMetadata(coll.results[0].id)));
                Console.WriteLine("===============================================================================");
                Console.WriteLine("Get active schima content ");
                Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.GetActiveSchemaContent(coll.results[0].id)));
                Console.WriteLine("===============================================================================");
            }

            return(si);
        }