jiraSOAP 0.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. data/.yardopts +10 -0
  2. data/ChangeLog +18 -0
  3. data/{LICENSE → LICENSE.txt} +0 -0
  4. data/README.markdown +4 -6
  5. data/lib/jiraSOAP.rb +0 -2
  6. data/lib/jiraSOAP/JIRAservice.rb +5 -5
  7. data/lib/jiraSOAP/api.rb +77 -696
  8. data/lib/jiraSOAP/api/additions.rb +22 -0
  9. data/lib/jiraSOAP/api/attachments.rb +33 -0
  10. data/lib/jiraSOAP/api/avatars.rb +64 -0
  11. data/lib/jiraSOAP/api/comments.rb +33 -0
  12. data/lib/jiraSOAP/api/filters.rb +20 -0
  13. data/lib/jiraSOAP/api/issue_data_types.rb +51 -0
  14. data/lib/jiraSOAP/api/issues.rb +102 -0
  15. data/lib/jiraSOAP/api/project_roles.rb +49 -0
  16. data/lib/jiraSOAP/api/projects.rb +67 -0
  17. data/lib/jiraSOAP/api/schemes.rb +17 -0
  18. data/lib/jiraSOAP/api/server_info.rb +18 -0
  19. data/lib/jiraSOAP/api/users.rb +35 -0
  20. data/lib/jiraSOAP/api/versions.rb +50 -0
  21. data/lib/jiraSOAP/entities.rb +5 -1
  22. data/lib/jiraSOAP/entities/attachment_metadata.rb +9 -22
  23. data/lib/jiraSOAP/entities/avatar.rb +10 -23
  24. data/lib/jiraSOAP/entities/comment.rb +12 -31
  25. data/lib/jiraSOAP/entities/component.rb +1 -1
  26. data/lib/jiraSOAP/entities/custom_field_value.rb +5 -11
  27. data/lib/jiraSOAP/entities/described_entity.rb +4 -4
  28. data/lib/jiraSOAP/entities/dynamic_entity.rb +5 -5
  29. data/lib/jiraSOAP/entities/entity.rb +28 -13
  30. data/lib/jiraSOAP/entities/field.rb +1 -1
  31. data/lib/jiraSOAP/entities/filter.rb +5 -14
  32. data/lib/jiraSOAP/entities/issue.rb +29 -88
  33. data/lib/jiraSOAP/entities/issue_property.rb +4 -4
  34. data/lib/jiraSOAP/entities/issue_security_scheme.rb +1 -1
  35. data/lib/jiraSOAP/entities/issue_type.rb +4 -5
  36. data/lib/jiraSOAP/entities/named_entity.rb +4 -4
  37. data/lib/jiraSOAP/entities/notification_scheme.rb +1 -1
  38. data/lib/jiraSOAP/entities/permission.rb +7 -10
  39. data/lib/jiraSOAP/entities/permission_mapping.rb +5 -10
  40. data/lib/jiraSOAP/entities/permission_scheme.rb +3 -4
  41. data/lib/jiraSOAP/entities/priority.rb +4 -3
  42. data/lib/jiraSOAP/entities/project.rb +9 -30
  43. data/lib/jiraSOAP/entities/project_role.rb +1 -1
  44. data/lib/jiraSOAP/entities/resolution.rb +1 -1
  45. data/lib/jiraSOAP/entities/scheme.rb +1 -1
  46. data/lib/jiraSOAP/entities/server_configuration.rb +14 -53
  47. data/lib/jiraSOAP/entities/server_info.rb +8 -26
  48. data/lib/jiraSOAP/entities/status.rb +1 -1
  49. data/lib/jiraSOAP/entities/time_info.rb +5 -10
  50. data/lib/jiraSOAP/entities/user.rb +5 -15
  51. data/lib/jiraSOAP/entities/username.rb +4 -0
  52. data/lib/jiraSOAP/entities/version.rb +6 -20
  53. data/lib/jiraSOAP/handsoap_extensions.rb +4 -2
  54. data/lib/jiraSOAP/macruby_bonuses.rb +12 -5
  55. data/lib/jiraSOAP/url.rb +13 -24
  56. data/yard-jiraSOAP.rb +65 -0
  57. metadata +52 -92
  58. data/lib/jiraSOAP/api/convenience.rb +0 -12
  59. data/lib/jiraSOAP/entities/remote_entity.rb +0 -7
@@ -0,0 +1,22 @@
1
+ module JIRA
2
+
3
+ # Methods declared here do not directly map to methods defined in JIRA's
4
+ # SOAP API javadoc. They are generally close to something from the javadoc
5
+ # but with some extra conveniences.
6
+ module RemoteAPIAdditions
7
+
8
+ # Returns the first field that exactly matches the given
9
+ # name, otherwise returns nil.
10
+ # @param [String] name
11
+ # @return [JIRA::Field,nil]
12
+ def get_custom_field_with_name name
13
+ get_custom_fields.each { |cf|
14
+ return cf if cf.name == name
15
+ }
16
+ nil
17
+ end
18
+
19
+ # @todo a method for getting attachments
20
+ end
21
+
22
+ end
@@ -0,0 +1,33 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with issue Attachments and their metadata
4
+
5
+ # @todo change method name to reflect that you only get metadata
6
+ # @param [String] issue_key
7
+ # @return [Array<JIRA::AttachmentMetadata>]
8
+ def get_attachments_for_issue_with_key issue_key
9
+ jira_call JIRA::AttachmentMetadata, 'getAttachmentsFromIssue', issue_key
10
+ end
11
+
12
+ # Expect this method to be slow.
13
+ # @param [String] issue_key
14
+ # @param [Array<String>] filenames names to put on the files
15
+ # @param [Array<String>] data base64 encoded data
16
+ # @return [Boolean] true if successful
17
+ def add_base64_encoded_attachments_to_issue_with_key issue_key, filenames, data
18
+ invoke('soap:addBase64EncodedAttachmentsToIssue') { |msg|
19
+ msg.add 'soap:in0', @auth_token
20
+ msg.add 'soap:in1', issue_key
21
+ msg.add 'soap:in2' do |submsg|
22
+ filenames.each { |filename| submsg.add 'filenames', filename }
23
+ end
24
+ msg.add 'soap:in3' do |submsg|
25
+ data.each { |datum| submsg.add 'base64EncodedData', datum }
26
+ end
27
+ }
28
+ true
29
+ end
30
+
31
+ # @endgroup
32
+ end
33
+ end
@@ -0,0 +1,64 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with Avatars
4
+
5
+ # Gets you the default avatar image for a project; if you want all
6
+ # the avatars for a project, use {#get_project_avatars_for_key}.
7
+ # @param [String] project_key
8
+ # @return [JIRA::Avatar]
9
+ def get_project_avatar_for_key project_key
10
+ JIRA::Avatar.new_with_xml call( 'getProjectAvatar', project_key ).first
11
+ end
12
+
13
+ # Gets ALL avatars for a given project with this method; if you
14
+ # just want the project avatar, use {#get_project_avatar_for_key}.
15
+ # @param [String] project_key
16
+ # @param [Boolean] include_default_avatars
17
+ # @return [Array<JIRA::Avatar>]
18
+ def get_project_avatars_for_key project_key, include_default_avatars = false
19
+ jira_call JIRA::Avatar, 'getProjectAvatars', project_key, include_default_avatars
20
+ end
21
+
22
+ # @note You cannot delete system avatars
23
+ # @note You need project administration permissions to delete an avatar
24
+ # @param [String] avatar_id
25
+ # @return [Boolean] true if successful
26
+ def delete_project_avatar_with_id avatar_id
27
+ call 'deleteProjectAvatar', avatar_id
28
+ true
29
+ end
30
+
31
+ # @note You need project administration permissions to edit an avatar
32
+ # @note JIRA does not care if the avatar_id is valid
33
+ # Change the project avatar to another existing avatar. If you want to
34
+ # upload a new avatar and set it to be the new project avatar use
35
+ # {#set_new_project_avatar_for_project_with_key} instead.
36
+ # @return [Boolean] true if successful
37
+ def set_project_avatar_for_project_with_key project_key, avatar_id
38
+ call 'setProjectAvatar', project_key, avatar_id
39
+ true
40
+ end
41
+
42
+ # @note You need project administration permissions to edit an avatar
43
+ # Use this method to create a new custom avatar for a project and set it
44
+ # to be current avatar for the project.
45
+ #
46
+ # The image, provided as base64 encoded data, should be a 48x48 pixel square.
47
+ # If the image is larger, the top left 48 pixels are taken, if it is smaller
48
+ # then it will be upscaled to 48 pixels.
49
+ # The small version of the avatar image (16 pixels) is generated
50
+ # automatically.
51
+ # If you want to switch a project avatar to an avatar that already exists on
52
+ # the system then use {#set_project_avatar_for_project_with_key} instead.
53
+ # @param [String] project_key
54
+ # @param [String] mime_type
55
+ # @param [String] base64_image
56
+ # @return [Boolean] true if successful
57
+ def set_new_project_avatar_for_project_with_key project_key, mime_type, base64_image
58
+ call 'setNewProjectAvatar', project_key, mime_type, base64_image
59
+ true
60
+ end
61
+
62
+ # @endgroup
63
+ end
64
+ end
@@ -0,0 +1,33 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with Comments
4
+
5
+ # @param [String] issue_key
6
+ # @param [JIRA::Comment] comment
7
+ # @return [Boolean] true if successful
8
+ def add_comment_to_issue_with_key issue_key, comment
9
+ call 'addComment', issue_key, comment
10
+ true
11
+ end
12
+
13
+ # @param [String] id
14
+ # @return [JIRA::Comment]
15
+ def get_comment_with_id id
16
+ JIRA::Comment.new_with_xml call( 'getComment', id ).first
17
+ end
18
+
19
+ # @param [String] issue_key
20
+ # @return [Array<JIRA::Comment>]
21
+ def get_comments_for_issue_with_key issue_key
22
+ jira_call JIRA::Comment, 'getComments', issue_key
23
+ end
24
+
25
+ # @param [JIRA::Comment] comment
26
+ # @return [JIRA::Comment]
27
+ def update_comment comment
28
+ JIRA::Comment.new_with_xml call( 'editComment', comment ).first
29
+ end
30
+
31
+ # @endgroup
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with Filters
4
+
5
+ # Retrieves favourite filters for the currently logged in user.
6
+ # @return [Array<JIRA::Filter>]
7
+ def get_favourite_filters
8
+ jira_call JIRA::Filter, 'getFavouriteFilters'
9
+ end
10
+ alias_method :get_favorite_filters, :get_favourite_filters
11
+
12
+ # @param [String] id
13
+ # @return [Fixnum]
14
+ def get_issue_count_for_filter_with_id id
15
+ call( 'getIssueCountForFilter', id ).to_i
16
+ end
17
+
18
+ # @endgroup
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with issue attributes
4
+
5
+ # @return [Array<JIRA::Priority>]
6
+ def get_priorities
7
+ jira_call JIRA::Priority, 'getPriorities'
8
+ end
9
+
10
+ # @return [Array<JIRA::Resolution>]
11
+ def get_resolutions
12
+ jira_call JIRA::Resolution, 'getResolutions'
13
+ end
14
+
15
+ # @return [Array<JIRA::Field>]
16
+ def get_custom_fields
17
+ jira_call JIRA::Field, 'getCustomFields'
18
+ end
19
+
20
+ # @return [Array<JIRA::IssueType>]
21
+ def get_issue_types
22
+ jira_call JIRA::IssueType, 'getIssueTypes'
23
+ end
24
+
25
+ # @return [Array<JIRA::Status>]
26
+ def get_statuses
27
+ jira_call JIRA::Status, 'getStatuses'
28
+ end
29
+
30
+ # @return [Array<JIRA::IssueType>]
31
+ def get_subtask_issue_types
32
+ jira_call JIRA::IssueType, 'getSubTaskIssueTypes'
33
+ end
34
+
35
+ # @param [String] project_id
36
+ # @return [Array<JIRA::IssueType>]
37
+ def get_subtask_issue_types_for_project_with_id project_id
38
+ jira_call JIRA::IssueType, 'getSubTaskIssueTypesForProject', project_id
39
+ end
40
+
41
+ # I have no idea what this method does.
42
+ # @todo find out what this method does
43
+ # @return [Boolean] true if no exceptions were raised
44
+ def refresh_custom_fields
45
+ call 'refreshCustomFields'
46
+ true
47
+ end
48
+
49
+ # @endgroup
50
+ end
51
+ end
@@ -0,0 +1,102 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with Issues
4
+
5
+ # This method is the equivalent of making an advanced search from the
6
+ # web interface.
7
+ #
8
+ # During my own testing, I found that HTTP requests could timeout for really
9
+ # large requests (~2500 results). So I set a more reasonable upper limit;
10
+ # feel free to override it, but be aware of the potential issues.
11
+ #
12
+ # The JIRA::Issue structure does not include any comments or attachments.
13
+ # @param [String] jql_query JQL query as a string
14
+ # @param [Fixnum] max_results limit on number of returned results;
15
+ # the value may be overridden by the server if max_results is too large
16
+ # @return [Array<JIRA::Issue>]
17
+ def get_issues_from_jql_search jql_query, max_results = 2000
18
+ jira_call JIRA::Issue, 'getIssuesFromJqlSearch', jql_query, max_results
19
+ end
20
+
21
+ # This method can update most, but not all, issue fields. Some limitations
22
+ # are because of how the API is designed, and some are because I have not
23
+ # yet implemented the ability to update fields made of custom objects (things
24
+ # in the JIRA module).
25
+ #
26
+ # Fields known to not update via this method:
27
+ # - status - use {#progress_workflow_action}
28
+ # - attachments - use {#add_base64_encoded_attachments_to_issue_with_key}
29
+ #
30
+ # Though JIRA::FieldValue objects have an id field, they do not expect to be
31
+ # given id values. You must use the name of the field you wish to update.
32
+ # @example Usage With A Normal Field
33
+ # summary = JIRA::FieldValue.new 'summary', ['My new summary']
34
+ # @example Usage With A Custom Field
35
+ # custom_field = JIRA::FieldValue.new 'customfield_10060', ['123456']
36
+ # @example Setting a field to be blank/nil
37
+ # description = JIRA::FieldValue.new 'description'
38
+ # @example Calling the method to update an issue
39
+ # jira_service_instance.update_issue 'PROJECT-1', description, custom_field
40
+ # @param [String] issue_key
41
+ # @param [JIRA::FieldValue] *field_values
42
+ # @return [JIRA::Issue]
43
+ def update_issue issue_key, *field_values
44
+ response = invoke('soap:updateIssue') { |msg|
45
+ msg.add 'soap:in0', @auth_token
46
+ msg.add 'soap:in1', issue_key
47
+ msg.add 'soap:in2' do |submsg|
48
+ field_values.each { |fv| fv.soapify_for submsg }
49
+ end
50
+ }
51
+ JIRA::Issue.new_with_xml response.document.xpath('//updateIssueReturn').first
52
+ end
53
+
54
+ # Some fields will be ignored when an issue is created.
55
+ # - reporter - you cannot override this value at creation
56
+ # - resolution
57
+ # - attachments
58
+ # - votes
59
+ # - status
60
+ # - due date - I think this is a bug in jiraSOAP or JIRA
61
+ # - environment - I think this is a bug in jiraSOAP or JIRA
62
+ # @param [JIRA::Issue] issue
63
+ # @return [JIRA::Issue]
64
+ def create_issue_with_issue issue
65
+ JIRA::Issue.new_with_xml call( 'createIssue', issue ).first
66
+ end
67
+
68
+ # @param [String] issue_key
69
+ # @return [JIRA::Issue]
70
+ def get_issue_with_key issue_key
71
+ JIRA::Issue.new_with_xml call( 'getIssue', issue_key ).first
72
+ end
73
+
74
+ # @param [String] issue_id
75
+ # @return [JIRA::Issue]
76
+ def get_issue_with_id issue_id
77
+ JIRA::Issue.new_with_xml call( 'getIssueById', issue_id ).first
78
+ end
79
+
80
+ # @param [String] id
81
+ # @param [Fixnum] max_results
82
+ # @param [Fixnum] offset
83
+ # @return [Array<JIRA::Issue>]
84
+ def get_issues_from_filter_with_id id, max_results = 500, offset = 0
85
+ jira_call JIRA::Issue, 'getIssuesFromFilterWithLimit', id, offset, max_results
86
+ end
87
+
88
+ # @param [String] issue_id
89
+ # @return [Time]
90
+ def get_resolution_date_for_issue_with_id issue_id
91
+ call( 'getResolutionDateById', issue_id ).to_date
92
+ end
93
+
94
+ # @param [String] issue_key
95
+ # @return [Time]
96
+ def get_resolution_date_for_issue_with_key issue_key
97
+ call( 'getResolutionDateByKey', issue_key ).to_date
98
+ end
99
+
100
+ # @endgroup
101
+ end
102
+ end
@@ -0,0 +1,49 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with Project Roles
4
+
5
+ # @return [Array<JIRA::ProjectRole>]
6
+ def get_project_roles
7
+ jira_call JIRA::ProjectRole, 'getProjectRoles'
8
+ end
9
+
10
+ # @param [String] role_id
11
+ # @return [JIRA::ProjectRole]
12
+ def get_project_role_with_id role_id
13
+ JIRA::ProjectRole.new_with_xml call( 'getProjectRole', role_id ).first
14
+ end
15
+
16
+ # @param [JIRA::ProjectRole] project_role
17
+ # @return [JIRA::ProjectRole] the role that was created
18
+ def create_project_role_with_role project_role
19
+ JIRA::ProjectRole.new_with_xml call( 'createProjectRole', project_role ).first
20
+ end
21
+
22
+ # @note JIRA 4.0 and 4.2 returns an exception if the name already exists
23
+ # Returns true if the name does not exist.
24
+ # @param [String] project_role_name
25
+ # @return [Boolean] true if successful
26
+ def project_role_name_unique? project_role_name
27
+ call( 'isProjectRoleNameUnique', project_role_name ).to_boolean
28
+ end
29
+
30
+ # @note the confirm argument appears to do nothing (at least on JIRA 4.0)
31
+ # @param [JIRA::ProjectRole] project_role
32
+ # @param [Boolean] confirm
33
+ # @return [Boolean] true if successful
34
+ def delete_project_role project_role, confirm = true
35
+ call 'deleteProjectRole', project_role, confirm
36
+ true
37
+ end
38
+
39
+ # @note JIRA 4.0 will not update project roles, it will instead throw
40
+ # an exception telling you that the project role already exists
41
+ # @param [JIRA::ProjectRole] project_role
42
+ # @return [JIRA::ProjectRole] the role after the update
43
+ def update_project_role_with_role project_role
44
+ JIRA::ProjectRole.new_with_xml call( 'updateProjectRole', project_role ).first
45
+ end
46
+
47
+ # @endgroup
48
+ end
49
+ end
@@ -0,0 +1,67 @@
1
+ module JIRA
2
+ module RemoteAPI
3
+ # @group Working with Projects
4
+
5
+ # You need to explicitly ask for schemes in order to get them. By
6
+ # default, most project fetching methods purposely leave out all
7
+ # the scheme information as permission schemes can be very large.
8
+ # @param [String] project_key
9
+ # @return [JIRA::Project]
10
+ def get_project_with_key project_key
11
+ JIRA::Project.new_with_xml call( 'getProjectByKey', project_key ).first
12
+ end
13
+
14
+ # Requires you to set at least a project name, key, and lead.
15
+ # However, it is also a good idea to set other project properties, such as
16
+ # the permission scheme as the default permission scheme can be too
17
+ # restrictive in most cases.
18
+ # @param [JIRA::Project] project
19
+ # @return [JIRA::Project]
20
+ def create_project_with_project project
21
+ JIRA::Project.new_with_xml call( 'createProjectFromObject', project ).first
22
+ end
23
+
24
+ # The id of the project is the only field that you cannot update. Or, at
25
+ # least the only field I know that you cannot update.
26
+ # @param [JIRA::Project] project
27
+ # @return [JIRA::Project]
28
+ def update_project_with_project project
29
+ JIRA::Project.new_with_xml call( 'updateProject', project ).first
30
+ end
31
+
32
+ # @param [String] project_id
33
+ # @return [JIRA::Project]
34
+ def get_project_with_id project_id
35
+ JIRA::Project.new_with_xml call( 'getProjectById', project_id ).first
36
+ end
37
+
38
+ # @todo parse the permission scheme
39
+ # @note This method does not yet include the permission scheme.
40
+ # @param [String] project_id
41
+ # @return [JIRA::Project]
42
+ def get_project_including_schemes_with_id project_id
43
+ JIRA::Project.new_with_xml call( 'getProjectWithSchemesById', project_id ).first
44
+ end
45
+
46
+ # @param [String] project_name
47
+ # @return [Array<JIRA::IssueType>]
48
+ def get_issue_types_for_project_with_id project_id
49
+ jira_call JIRA::IssueType, 'getIssueTypesForProject', project_id
50
+ end
51
+
52
+ # @note This will not fill in JIRA::Scheme data for the projects.
53
+ # @return [Array<JIRA::Project>]
54
+ def get_projects_without_schemes
55
+ jira_call JIRA::Project, 'getProjectsNoSchemes'
56
+ end
57
+
58
+ # @param [String] project_key
59
+ # @return [Boolean] true if successful
60
+ def delete_project_with_key project_key
61
+ call 'deleteProject', project_key
62
+ true
63
+ end
64
+
65
+ # @endgroup
66
+ end
67
+ end