conf-api-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3bbf76797953e4686c4e2a606ea063dc8a2c3370
4
+ data.tar.gz: 3d1470f355876396fe8f82f7351c65b50dc44b50
5
+ SHA512:
6
+ metadata.gz: 8c54c32fdfa7f1954b278dedb1348f7b665ef91fe84bf53bc9dc8d9ef144d18faee66bec80f95113c69cb5cf46c4e24dbcbd26666306473e28690994b22f3e24
7
+ data.tar.gz: 80347e8d63ca7959f67976b49978ef68a923452f16ed9b3bd1554dd4260db13f3870ac3f24e9f53209ad2943fb5b73e4988bed224d92b12f1228500f8ffbf576
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Alex Mishyn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Conf::Api::Client
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/confluence/api/client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'conf-api-client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install conf-api-client
22
+
23
+ ## Usage
24
+
25
+ require 'rubygems'
26
+ require 'conf/api/client'
27
+
28
+ username = 'username'
29
+ password = 'password'
30
+ space = 'Home'
31
+ url = 'https://company.atlassian.net/wiki'
32
+
33
+ # Note: url is automatically appended with /rest/api/content so if your
34
+ # Confluence base URL is different from "/wiki" specify it above
35
+
36
+ client = Confluence::Api::Client.new(username, password, url)
37
+ page = client.get({spaceKey: space, title: 'September'})[0]
38
+ client.create({type:"page",title: "title", space: {key: space}, ancestors:[{type:"page",id: page['id']}]})
39
+
40
+ ## API Links
41
+
42
+ https://developer.atlassian.com/confdev/confluence-rest-api
43
+ https://developer.atlassian.com/confdev/confluence-rest-api/confluence-rest-api-examples
44
+
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it ( https://github.com/pegasd/conf-api-client/fork )
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create a new Pull Request
59
+
60
+
61
+ ## TODO
62
+
63
+ 1. Cover with tests
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "confluence/api/client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'conf/api/client/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'conf-api-client'
9
+ spec.version = Conf::Api::Client::VERSION
10
+ spec.authors = ['Alex Mishyn', 'Serdar Gokay Kucuk', 'Vladimir Tyshkevich', 'Eugene Piven']
11
+ spec.email = ['epiven@gmail.com']
12
+ spec.homepage = 'https://github.com/pegasd/conf-api-client'
13
+ spec.summary = 'Rest client to confluence JSON api'
14
+ spec.description = 'Rest client to confluence api with ability to upload files and edit pages.'
15
+ spec.license = 'MIT'
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler'
21
+ spec.add_development_dependency 'rake'
22
+
23
+ spec.add_runtime_dependency 'json', '~> 2'
24
+ spec.add_runtime_dependency 'faraday', '~> 0.12'
25
+ spec.add_runtime_dependency 'mimemagic', '~> 0.3'
26
+ end
@@ -0,0 +1,51 @@
1
+ require 'conf/api/client/version'
2
+ require 'json'
3
+ require 'faraday'
4
+
5
+ module Conf
6
+ module Api
7
+ class Client
8
+ attr_accessor :user, :pass, :url, :conn
9
+
10
+ def initialize(user, pass, url)
11
+ self.user = user
12
+ self.pass = pass
13
+ self.url = url
14
+ self.conn = Faraday.new(url: url) do |faraday|
15
+ faraday.request :url_encoded # form-encode POST params
16
+ # faraday.response :logger # log requests to STDOUT
17
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
18
+ faraday.basic_auth(self.user, self.pass)
19
+ end
20
+ end
21
+
22
+ def get(params)
23
+ response = conn.get('/rest/api/content', params)
24
+ JSON.parse(response.body)['results']
25
+ end
26
+
27
+ def get_by_id(id)
28
+ response = conn.get('/rest/api/content/' + id)
29
+ JSON.parse(response.body)
30
+ end
31
+
32
+ def create(params)
33
+ response = conn.post do |req|
34
+ req.url '/rest/api/content'
35
+ req.headers['Content-Type'] = 'application/json'
36
+ req.body = params.to_json
37
+ end
38
+ JSON.parse(response.body)
39
+ end
40
+
41
+ def update(id, params)
42
+ response = conn.put do |req|
43
+ req.url "/rest/api/content/#{id}"
44
+ req.headers['Content-Type'] = 'application/json'
45
+ req.body = params.to_json
46
+ end
47
+ JSON.parse(response.body)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ module Conf
2
+ module Api
3
+ class Client
4
+ VERSION = '0.1.0'.freeze
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: conf-api-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex Mishyn
8
+ - Serdar Gokay Kucuk
9
+ - Vladimir Tyshkevich
10
+ - Eugene Piven
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2017-08-21 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: json
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '2'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '2'
58
+ - !ruby/object:Gem::Dependency
59
+ name: faraday
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: '0.12'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '0.12'
72
+ - !ruby/object:Gem::Dependency
73
+ name: mimemagic
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '0.3'
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '0.3'
86
+ description: Rest client to confluence api with ability to upload files and edit pages.
87
+ email:
88
+ - epiven@gmail.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - ".rspec"
95
+ - ".travis.yml"
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - conf-api-client.gemspec
104
+ - lib/conf/api/client.rb
105
+ - lib/conf/api/client/version.rb
106
+ homepage: https://github.com/pegasd/conf-api-client
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.6.12
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Rest client to confluence JSON api
130
+ test_files: []