jenkins-bot has submitted this change and it was merged.

Change subject: Adding and fixing API examples
......................................................................


Adding and fixing API examples

Change-Id: Ie18eca3b051ea1435e526ea1c0c990d9f6f49695
Bug: 48724
---
M repo/includes/api/CreateClaim.php
M repo/includes/api/EditEntity.php
M repo/includes/api/GetClaims.php
M repo/includes/api/GetEntities.php
M repo/includes/api/LinkTitles.php
M repo/includes/api/RemoveClaims.php
M repo/includes/api/RemoveQualifiers.php
M repo/includes/api/RemoveReferences.php
M repo/includes/api/SearchEntities.php
M repo/includes/api/SetClaim.php
M repo/includes/api/SetClaimValue.php
M repo/includes/api/SetDescription.php
M repo/includes/api/SetQualifier.php
M repo/includes/api/SetReference.php
M repo/includes/api/SetSiteLink.php
15 files changed, 64 insertions(+), 41 deletions(-)

Approvals:
  Aude: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/api/CreateClaim.php 
b/repo/includes/api/CreateClaim.php
index 9267bda..8248495 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -328,8 +328,7 @@
        protected function getExamples() {
                return array(
                        
'api.php?action=wbcreateclaim&entity=q42&property=p9001&snaktype=novalue&token=foobar&baserevid=7201010',
-                       
'api.php?action=wbcreateclaim&entity=q42&property=p9001&snaktype=value&value={"entity-type":"item","numeric-id":1}&token=foobar&baserevid=7201010',
-                       // 'ex' => 'desc'
+                       
'api.php?action=wbcreateclaim&entity=q42&property=p9001&snaktype=value&value={"entity-type":"item","numeric-id":1}&token=foobar&baserevid=7201010'
 => 'Creates a claim for q42 of p101 with a value of q1',
                );
        }
 }
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 543b042..2fbcd0a 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -504,10 +504,16 @@
         */
        protected function getExamples() {
                return array(
-                       'api.php?action=wbeditentity&data={}&format=jsonfm'
-                       => 'Set an empty JSON structure for the entity, it will 
be extended with an id and the structure cleansed and completed. Report it as 
pretty printed json format.',
-                       
'api.php?action=wbeditentity&data={"labels":{"de":{"language":"de","value":"de-value"},"en":{"language":"en","value":"en-value"}}}'
-                       => 'Set a more complete JSON structure for the entity, 
it will be extended with an id and the structure cleansed and completed.',
+                       'api.php?action=wbeditentity&new=item&data={}'
+                       => 'Create a new empty item, returns extended with the 
item structure',
+                       'api.php?action=wbeditentity&clear=true&id=q42&data={}'
+                       => 'Clear item with id q42',
+                       
'api.php?action=wbeditentity&new=item&data={"labels":{"de":{"language":"de","value":"de-value"},"en":{"language":"en","value":"en-value"}}}'
+                       => 'Create a new item and set labels for de and en',
+                       
'api.php?action=wbeditentity&new=property&data={"labels":{"en-gb":{"language":"en-gb","value":"Propertylabel"}},"descriptions":{"en-gb":{"language":"en-gb","value":"Propertydescription"}},"datatype":"string"}'
+                       => 'Create a new property containing the json data, 
returns extended with the item structure',
+                       
'api.php?action=wbeditentity&id=q42&data={"sitelinks":{"nowiki":"København","svwiki":"Köpenhamn"}}'
+                       => 'Sets sitelinks for nowiki and svwiki, overwriting 
them if they already exist',
                );
        }
 
diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php
index 1c71a93..9502d40 100644
--- a/repo/includes/api/GetClaims.php
+++ b/repo/includes/api/GetClaims.php
@@ -44,7 +44,6 @@
  */
 class GetClaims extends ApiWikibase {
 
-       // TODO: example
        // TODO: rights
        // TODO: conflict detection
 
@@ -129,7 +128,7 @@
                $claims = array();
                $params = $this->extractRequestParams();
 
-               // TODO: we probably need this elswhere, so make filter methods 
in Claim
+               // TODO: we probably need this elsewhere, so make filter 
methods in Claim
                $rank = isset( $params['rank'] ) ? 
ClaimSerializer::unserializeRank( $params['rank'] ) : false;
                $propertyId = isset( $params['property'] ) ? 
$params['property'] : false;
 
@@ -264,8 +263,10 @@
         */
        protected function getExamples() {
                return array(
-                       // TODO
-                       // 'ex' => 'desc'
+                       "api.php?action=wbgetclaims&entity=q42" => "Get claims 
for item with ID q42",
+                       "api.php?action=wbgetclaims&entity=q42&property=p2" => 
"Get claims for item with ID q42 and property with ID p2",
+                       "api.php?action=wbgetclaims&entity=q42&rank=normal" => 
"Get claims for item with ID q42 that are ranked as normal",
+                       
'api.php?action=wbgetclaims&claim=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F' => 
"Get claim with GUID of q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F",
                );
        }
 
diff --git a/repo/includes/api/GetEntities.php 
b/repo/includes/api/GetEntities.php
index 9969088..6c57165 100644
--- a/repo/includes/api/GetEntities.php
+++ b/repo/includes/api/GetEntities.php
@@ -304,14 +304,23 @@
         * @see \ApiBase::getExamples()
         */
        protected function getExamples() {
-               $exampleId = new EntityId( Item::ENTITY_TYPE, 42 );
-               $exampleId = $exampleId->getPrefixedId();
-
                return array(
-                       "api.php?action=wbgetentities&ids=$exampleId"
-                       => "Get item with ID $exampleId with language 
attributes in all available languages",
-                       
"api.php?action=wbgetentities&ids=$exampleId&languages=en"
-                       => "Get item with ID $exampleId with language 
attributes in English language",
+                       "api.php?action=wbgetentities&ids=q42"
+                       => "Get entity with ID q42 with all available 
attributes in all available languages",
+                       "api.php?action=wbgetentities&ids=p2"
+                       => "Get entity with ID p2 with all available attributes 
in all available languages",
+                       "api.php?action=wbgetentities&ids=q42|p2"
+                       => "Get entities with IDs q42 and p2 with all available 
attributes in all available languages",
+                       "api.php?action=wbgetentities&ids=q42&languages=en"
+                       => "Get entity with ID q42 with all available 
attributes in English language",
+                       "api.php?action=wbgetentities&ids=q42&props=labels"
+                       => "Get entity with ID q42 showing all labels in all 
available languages",
+                       "api.php?action=wbgetentities&ids=p2|p3&props=datatype"
+                       => "Get entities with IDs p2 and p3 showing only 
datatypes",
+                       
"api.php?action=wbgetentities&ids=q42&props=aliases&languages=en"
+                       => "Get entity with ID q42 showing all aliases in 
English language",
+                       
"api.php?action=wbgetentities&ids=q1|q42&props=descriptions&languages=en|de|fr"
+                       => "Get entities with IDs q1 and q42 showing 
descriptions in English, German and French languages",
                        
'api.php?action=wbgetentities&sites=enwiki&titles=Berlin&languages=en'
                        => 'Get the item for page "Berlin" on the site 
"enwiki", with language attributes in English language',
                );
diff --git a/repo/includes/api/LinkTitles.php b/repo/includes/api/LinkTitles.php
index 5254052..443a190 100644
--- a/repo/includes/api/LinkTitles.php
+++ b/repo/includes/api/LinkTitles.php
@@ -252,6 +252,9 @@
                                'and the requester should then start using the 
new token from the next request, possibly when',
                                'repeating a failed request.'
                        ),
+                       'bot' => array( 'Mark this edit as bot',
+                               'This URL flag will only be respected if the 
user belongs to the group "bot".'
+                       ),
                ) );
        }
 
diff --git a/repo/includes/api/RemoveClaims.php 
b/repo/includes/api/RemoveClaims.php
index 4883629..64650f4 100644
--- a/repo/includes/api/RemoveClaims.php
+++ b/repo/includes/api/RemoveClaims.php
@@ -364,8 +364,7 @@
         */
        protected function getExamples() {
                return array(
-                       // TODO
-                       // 'ex' => 'desc'
+                       
'api.php?action=wbremoveclaims&claim=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0N&token=foobar&baserevid=7201010'
 => 'Remove claim with GUID of "q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0N"',
                );
        }
 
diff --git a/repo/includes/api/RemoveQualifiers.php 
b/repo/includes/api/RemoveQualifiers.php
index 9dbb802..d9c91d5 100644
--- a/repo/includes/api/RemoveQualifiers.php
+++ b/repo/includes/api/RemoveQualifiers.php
@@ -44,7 +44,6 @@
 class RemoveQualifiers extends ApiWikibase {
 
        // TODO: automcomment
-       // TODO: example
        // TODO: rights
        // TODO: conflict detection
        // TODO: claim uniqueness
@@ -190,7 +189,7 @@
        public function getParamDescription() {
                return array(
                        'claim' => 'A GUID identifying the claim from which to 
remove qualifiers',
-                       'qualifiers' => 'Snak hashes of the querliers to 
remove',
+                       'qualifiers' => 'Snak hashes of the qualifiers to 
remove',
                        'token' => 'An "edittoken" token previously obtained 
through the token module (prop=info).',
                        'baserevid' => array(
                                'The numeric identifier for the revision to 
base the modification on.',
@@ -224,8 +223,7 @@
         */
        protected function getExamples() {
                return array(
-                       // TODO
-                       // 'ex' => 'desc'
+                       
'api.php?action=wbremovequalifiers&statement=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F&references=1eb8793c002b1d9820c833d234a1b54c8e94187e&token=foobar&baserevid=7201010'
 => 'Remove qualifier with hash "1eb8793c002b1d9820c833d234a1b54c8e94187e" from 
claim with GUID of "q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F"',
                );
        }
 
diff --git a/repo/includes/api/RemoveReferences.php 
b/repo/includes/api/RemoveReferences.php
index fd680ef..3aff07c 100644
--- a/repo/includes/api/RemoveReferences.php
+++ b/repo/includes/api/RemoveReferences.php
@@ -50,7 +50,6 @@
        }
 
        // TODO: automcomment
-       // TODO: example
        // TODO: rights
        // TODO: conflict detection
 
@@ -234,8 +233,7 @@
         */
        protected function getExamples() {
                return array(
-                       // TODO
-                       // 'ex' => 'desc'
+                       
'api.php?action=wbremovereferences&statement=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F&references=455481eeac76e6a8af71a6b493c073d54788e7e9&token=foobar&baserevid=7201010'
 => 'Remove reference with hash "455481eeac76e6a8af71a6b493c073d54788e7e9" from 
claim with GUID of "q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F"',
                );
        }
 
diff --git a/repo/includes/api/SearchEntities.php 
b/repo/includes/api/SearchEntities.php
index 2f270b3..6588465 100644
--- a/repo/includes/api/SearchEntities.php
+++ b/repo/includes/api/SearchEntities.php
@@ -294,8 +294,9 @@
         */
        protected function getExamples() {
                return array(
-                       'api.php?action=wbsearchentities&search=abc&language=en'
-                       => 'Search for "abc" in English language, with defaults 
for type and limit.',
+                       
'api.php?action=wbsearchentities&search=abc&language=en' => 'Search for "abc" 
in English language, with defaults for type and limit',
+                       
'api.php?action=wbsearchentities&search=abc&language=en&limit=50' => 'Search 
for "abc" in English language with a limit of 50',
+                       
'api.php?action=wbsearchentities&search=alphabet&language=en&type=property' => 
'Search for "alphabet" in English language for type property',
                );
        }
 
diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php
index 050be43..2c76fe1 100644
--- a/repo/includes/api/SetClaim.php
+++ b/repo/includes/api/SetClaim.php
@@ -227,8 +227,8 @@
         */
        protected function getExamples() {
                return array(
-                       
'api.php?action=setclaim&claim={json-stuff}&baserevid=9042&token=foobar'
-                       // 'ex' => 'desc'
+                       
'api.php?action=setclaim&claim={"id":"q2$5627445f-43cb-ed6d-3adb-760e85bd17ee","type":"claim","mainsnak":{"snaktype":"value","property":"p1","datavalue":{"value":"City","type":"string"}}}'
+                       => 'Set the claim with the given id to property p1 with 
a string value of "City',
                );
        }
 }
diff --git a/repo/includes/api/SetClaimValue.php 
b/repo/includes/api/SetClaimValue.php
index 4204ccc..8f01424 100644
--- a/repo/includes/api/SetClaimValue.php
+++ b/repo/includes/api/SetClaimValue.php
@@ -296,11 +296,9 @@
         */
        protected function getExamples() {
                return array(
-                       // TODO
-                       // 'ex' => 'desc'
+                       
'api.php?action=wbsetclaimvalue&claim=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F&snaktype=value&value={"entity-type":"item","numeric-id":1}&token=foobar&baserevid=7201010'
 => 'Sets the claim with the GUID of q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F 
to a value of q1',
                );
        }
-
 
        /**
         * @see \Wikibase\Api\IAutocomment::getTextForComment()
diff --git a/repo/includes/api/SetDescription.php 
b/repo/includes/api/SetDescription.php
index 6a9f789..6af7132 100644
--- a/repo/includes/api/SetDescription.php
+++ b/repo/includes/api/SetDescription.php
@@ -96,6 +96,8 @@
                return array(
                        
'api.php?action=wbsetdescription&id=Q42&language=en&value=An%20encyclopedia%20that%20everyone%20can%20edit'
                                => 'Set the string "An encyclopedia that 
everyone can edit" for page with id "Q42" as a decription in English language',
+                       
'api.php?action=wbsetdescription&site=enwiki&title=Wikipedia&language=en&value=An%20encyclopedia%20that%20everyone%20can%20edit'
+                               => 'Set the string "An encyclopedia that 
everyone can edit" as a decription in English language for page with a sitelink 
to enwiki:Wikipedia',
                );
        }
 
diff --git a/repo/includes/api/SetQualifier.php 
b/repo/includes/api/SetQualifier.php
index 4ee94e3..3125cdc 100644
--- a/repo/includes/api/SetQualifier.php
+++ b/repo/includes/api/SetQualifier.php
@@ -55,7 +55,6 @@
 class SetQualifier extends ApiWikibase {
 
        // TODO: automcomment
-       // TODO: example
        // TODO: rights
        // TODO: conflict detection
        // TODO: more explicit support for snak merging?
@@ -461,8 +460,7 @@
         */
        protected function getExamples() {
                return array(
-                       // TODO
-                       // 'ex' => 'desc'
+                       
'api.php?action=wbsetqualifier&claim=q2$4554c0f4-47b2-1cd9-2db9-aa270064c9f3&property=q1&value=GdyjxP8I6XB3&snaktype=value&token=foobar'
 => 'Set the qualifier for the given claim to string value GdyjxP8I6XB3',
                );
        }
 
diff --git a/repo/includes/api/SetReference.php 
b/repo/includes/api/SetReference.php
index 3dfe76f..f638c95 100644
--- a/repo/includes/api/SetReference.php
+++ b/repo/includes/api/SetReference.php
@@ -48,7 +48,6 @@
 class SetReference extends ApiWikibase {
 
        // TODO: automcomment
-       // TODO: example
        // TODO: rights
        // TODO: conflict detection
 
@@ -323,6 +322,16 @@
        }
 
        /**
+        * @see \ApiBase::getExamples()
+        */
+       protected function getExamples() {
+               return array(
+                       
'api.php?action=wbsetreference&statement=q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF&snaks={"p39":[{"snaktype":"value","property":"p14","datavalue":{"type":"string","value":"wikipedia"}}}&baserevid=7201010&token=foobar'
 => 'Create a new reference for claim with GUID 
q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF',
+                       
'api.php?action=wbsetreference&statement=q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF&reference=1eb8793c002b1d9820c833d234a1b54c8e94187e&snaks={"p39":[{"snaktype":"value","property":"p14","datavalue":{"type":"string","value":"wikipedia"}}}&baserevid=7201010&token=foobar'
 => 'Set reference for claim with GUID q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF 
which has hash of 1eb8793c002b1d9820c833d234a1b54c8e94187e',
+               );
+       }
+
+       /**
         * @see \ApiBase::isWriteMode()
         */
        public function isWriteMode() {
diff --git a/repo/includes/api/SetSiteLink.php 
b/repo/includes/api/SetSiteLink.php
index ca4be9a..5ba931b 100644
--- a/repo/includes/api/SetSiteLink.php
+++ b/repo/includes/api/SetSiteLink.php
@@ -202,10 +202,12 @@
         */
        protected function getExamples() {
                return array(
-                       
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Wikimedia'
-                       => 'Add title "Wikimedia" for English page with id 
"Q42" if the site link does not exist',
-                       
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Wikimedia&summary=World%20domination%20will%20be%20mine%20soon!'
-                       => 'Add title "Wikimedia" for English page with id 
"Q42", if the site link does not exist',
+                       
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Hydrogen'
+                       => 'Add a sitelink "Hydrogen" for English page with id 
"Q42", if the site link does not exist',
+                       
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Hydrogen&summary=World%20domination%20will%20be%20mine%20soon!'
+                       => 'Add a sitelink "Hydrogen" for English page with id 
"Q42", if the site link does not exist with an edit summary of "World 
domination will be mine soon!"',
+                       
'api.php?action=wbsetsitelink&site=enwiki&title=Hydrogen&tosite=dewiki&totitle=Wasserstoff'
+                       => 'Add a sitelink "Wasserstoff" for the German page on 
item with the link from the English page to "Hydrogen", if the site link does 
not exist',
                );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/71610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie18eca3b051ea1435e526ea1c0c990d9f6f49695
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Anja Jentzsch <[email protected]>
Gerrit-Reviewer: Ataherivand <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Bene <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jens Ohlig <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: John Erling Blad <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Liangent <[email protected]>
Gerrit-Reviewer: Lydia Pintscher <[email protected]>
Gerrit-Reviewer: Markus Kroetzsch <[email protected]>
Gerrit-Reviewer: Nikola Smolenski <[email protected]>
Gerrit-Reviewer: Nilesh <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to