Esempio n. 1
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic newStory = v1.Create(new {
                AssetType   = "Story",
                Scope       = "Scope:1015",
                Name        = $"Test Story Scope:1015 Update scalar attribute",
                Description = "I am not going to change this description after it is set"
            });

            dynamic retrievedStory = v1.Query(newStory.Oid).Select("Name", "Description").RetrieveFirst();

            retrievedStory.Name = $"{newStory.Name} - Name updated";

            v1.Update(retrievedStory);

            dynamic updatedRetrievedStory = v1.Query(retrievedStory.Oid).Select("Name", "Description").RetrieveFirst();

            WriteLine($"{newStory.Oid} original name: {newStory.Name}");
            WriteLine($"{retrievedStory.Oid} updated name: {updatedRetrievedStory.Name}");
            WriteLine($"{newStory.Oid} original description: {newStory.Description}");
            WriteLine($"{updatedRetrievedStory.Oid} non-updated description: {updatedRetrievedStory.Description}");

            WriteLine("Now we are going to try updating the original newStory object...");

            newStory.Name = "Test Story Scope:1015 updated on original newStory object!";
            v1.Update(newStory);

            dynamic newStoryFetchedAfterUpdate = v1.Query(newStory.Oid).Select("Name").RetrieveFirst();

            WriteLine($"{newStoryFetchedAfterUpdate.Oid} updated name is: {newStoryFetchedAfterUpdate.Name}");
        }
        public List <Story> GetAll()
        {
            List <Story> storyList = new List <Story>();

            string instanceUrl = "https://www16.v1host.com/api-examples/api/asset";
            string accessToken = "1.bndNO51GiliELZu1bbQdq3omgRI=";

            var v1 = new AssetClient(instanceUrl, accessToken);


            var assets = v1
                         .Query("Story")
                         .Select("Name", "Scope", "Estimate", "Description", "Number", "IsClosed")
                         .Retrieve();

            foreach (dynamic story in assets)
            {
                storyList.Add(new Story
                {
                    Href        = story.Oid,
                    Scope       = story.Scope.Oid,
                    Name        = story.Name,
                    Description = story.Description,
                    Number      = story.Number,
                    IsClosed    = Convert.ToBoolean(story.IsClosed)
                                  //Attachments
                                  //Owners
                });
            }

            return(storyList);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var story = v1.Create(new
            {
                AssetType = "Story",
                Scope     = "Scope:0",
                Name      = "My Story",
                Children  = new []
                {
                    new
                    {
                        AssetType = "Test",
                        Name      = "Test"
                    },
                    new
                    {
                        AssetType = "Task",
                        Name      = "Task"
                    }
                }
            });

            dynamic queriedStory = v1
                                   .Query(story.Oid)
                                   .Select("Name", "Scope")
                                   .RetrieveFirst();

            WriteLine(queriedStory.Oid);
            WriteLine(queriedStory.Name);
            WriteLine(queriedStory["Scope"].Oid);
            WriteLine(queriedStory.Scope.Oid);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic results = v1
                              .Query("Epic")
                              .Where("Scope.Name", "Josh API Test")
                              .Select(
                "Name",
                From("Subs")
                .Select(
                    "Name",
                    From("Children")
                    .Select(
                        "Name", "AssetType"
                        )
                    )
                )
                              .Retrieve();

            foreach (var result in results)
            {
                WriteLine(result);
            }
        }
Esempio n. 5
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var assets = v1
                         .Query("Scope")
                         .Select("Name", "Description", "Status", "Members", "Workitems:Defect")
                         .Retrieve();

            foreach (dynamic scope in assets)
            {
                WriteLine(scope.Oid);
                WriteLine(scope.Description);
                WriteLine(scope.Status);
                WriteLine($"Members count: {scope.Members.Count}");
                foreach (dynamic member in scope.Members)
                {
                    WriteLine(member);
                }
                WriteLine($"Defects count: {scope["Workitems:Defect"].Count}");
                foreach (dynamic defect in scope["Workitems:Defect"])
                {
                    WriteLine(defect);
                }
                WriteLine("---");
            }

            /* Expect to produce:
             *
             * If 3 Scopes available, then:
             *
             * Scope:00001
             * First scope
             * null // when there is no Status
             * Members count: 2
             * Member:20
             * Member:90
             * Defects count: 2
             * Defect:00010
             * Defect:00011
             * ---
             * Scope:00002
             * Second scope
             * ScopeStatus:1012
             * Members count: 2
             * Member:20
             * Member:400
             * Defects count: 1
             * Defect:00012
             * ----
             * Scope:00003
             * Third scope
             * null // when there is no Status
             * Members count: 1
             * Member:20 // Always one member in this particular Multi-Value relation
             * Defects count: 0
             */
        }
Esempio n. 6
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic epic = v1.Create(Attributes(
                                         ("AssetType", "Epic"),
                                         ("Scope", "Scope:0"),
                                         ("Name", "Epic made from a Tuple"),
                                         ("Subs", Assets(
                                              Asset(
                                                  "Story",
                                                  ("Name", "Story 1 from a Tuple"),
                                                  ("Children", Assets(
                                                       Asset("Test", ("Name", "Test 1 from a Tuple")),
                                                       Asset("Task", ("Name", "Task 1 from a Tuple"))
                                                       ))
                                                  ),
                                              Asset(
                                                  "Story",
                                                  ("Name", "Story 2 from a Tuple"),
                                                  ("Children", Assets(
                                                       Asset("Test", ("Name", "Test 2 from a Tuple")),
                                                       Asset("Task", ("Name", "Task 2 from a Tuple"))
                                                       ))
                                                  )
                                              ))
                                         ));

            WriteLine("Epic returned from .Create (which does not requery the system, but fills in Oids linearly from server response):");
            PrintEpic(epic);

            epic = v1
                   .Query(epic.Oid)
                   .Select(
                "Name",
                "Scope",
                From("Subs")
                .Select(
                    "AssetType",
                    "Name",
                    From("Children")
                    .Select(
                        "AssetType",
                        "Name"
                        )
                    )
                )
                   .RetrieveFirst();

            WriteLine();
            WriteLine("Epic returned from .Query, requerying the system with subselect syntax to pull in nested relationships:");
            PrintEpic(epic);
        }
        public void Execute()
        {
            const string scopeOid = "Scope:1015";

            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic scope = v1
                            .Query(scopeOid)
                            .Select("Workitems:Story")
                            .RetrieveFirst();

            WriteLine($"Story count: {scope["Workitems:Story"].Count}");
            foreach (var story in scope["Workitems:Story"])
            {
                WriteLine(story);
            }
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var assets = v1
                         .Query("Story")
                         .Where("Number", "S-01001")
                         .Select("Name", "Number")
                         .Retrieve();

            foreach (dynamic story in assets)
            {
                WriteLine(story.Oid);
                WriteLine(story.Name);
                WriteLine(story.Number);
            }
        }
Esempio n. 9
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var epicDict = new Dictionary <string, object>()
            {
                { "AssetType", "Epic" },
                { "Scope", "Scope:0" },
                { "Name", "My Epic" },
                { "Subs", new []
                  {
                      new Dictionary <string, object>()
                      {
                          { "AssetType", "Story" },
                          { "Name", "My Epic : My Story 1" },
                          { "Children", new []
                                            {
                                                new Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Test" },
                                                    { "Name", "My Story 1: Test" }
                                                },
                                                new  Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Task" },
                                                    { "Name", "My Story 1: Task" }
                                                }
                                            } }
                      },
                      new Dictionary <string, object>()
                      {
                          { "AssetType", "Story" },
                          { "Name", "My Epic : My Story 2" },
                          { "Children", new []
                                            {
                                                new Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Test" },
                                                    { "Name", "My Story 2: Test" }
                                                },
                                                new  Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Task" },
                                                    { "Name", "My Story 2: Task" }
                                                }
                                            } }
                      }
                  } }
            };

            dynamic epic = v1.Create(epicDict);

            WriteLine("Epic returned from .Create (which does not requery the system, but fills in Oids linearly from server response):");
            PrintEpic(epic);

            epic = v1
                   .Query(epic.Oid)
                   .Select(
                "Name",
                "Scope",
                From("Subs")
                .Select(
                    "AssetType",
                    "Name",
                    From("Children")
                    .Select(
                        "AssetType",
                        "Name"
                        )
                    )
                )
                   .RetrieveFirst();

            WriteLine();
            WriteLine("Epic returned from .Query, requerying the system with subselect syntax to pull in nested relationships:");
            PrintEpic(epic);
        }
Esempio n. 10
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var epic = Asset("Epic", new
            {
                Scope = "Scope:0",
                Name  = "My Epic",
                Subs  = Assets(
                    Asset("Story", new
                {
                    Name     = "My Epic : My Story 1",
                    Children = Assets(
                        Asset("Test", new
                    {
                        Name = "My Story 1: Test"
                    }),
                        Asset("Task", new
                    {
                        Name = "My Story 1: Task"
                    })
                        )
                }),
                    Asset("Story", new
                {
                    Name     = "My Epic : My Story 2",
                    Children = Assets(
                        Asset("Test", new
                    {
                        Name = "My Story 2: Test"
                    }),
                        Asset("Task", new
                    {
                        Name = "My Story 2: Task"
                    })
                        )
                })
                    )
            });

            // TODO: probably should be void in this case
            epic = v1.Create(epic);

            WriteLine("Epic returned from .Create (which does not requery the system, but fills in Oids linearly from server response):");
            PrintEpic(epic);

            epic = v1
                   .Query(epic.Oid)
                   .Select(
                "Name",
                "Scope",
                From("Subs")
                .Select(
                    "AssetType",
                    "Name",
                    From("Children")
                    .Select(
                        "AssetType",
                        "Name"
                        )
                    )
                )
                   .RetrieveFirst();

            WriteLine();
            WriteLine("Epic returned from .Query, requerying the system with subselect syntax to pull in nested relationships:");
            PrintEpic(epic);
        }