microsoft_kiota_faraday 0.9.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
+ SHA256:
3
+ metadata.gz: 3ed4dfb9cf94922a3682645363ddc89c4f2b56c46a2c956f0dd9f3bc59aeb251
4
+ data.tar.gz: 3fa85ddafb2c648892c93f02b4639491f5abef2cf156e16e8a1df4b5ceace8f6
5
+ SHA512:
6
+ metadata.gz: 756fdc8483daf374d04369e19020e9df2a30e5204f8f3221ed72f2f141120e605fb338dc370b650db653aea85551b6bf72e006c6ae4ed65950b3ed6ef0d8df5d
7
+ data.tar.gz: 452630029c70e993ab61d92a32c2d04642edcf41955ec43ac77bce9851fb735f2d4440985bf8266e89b81544cf4c6f1eac56dd4b90676710c6ae835a0abffc98
@@ -0,0 +1 @@
1
+ * @andrueastman @baywet @darrelmiller @zengin @MichaelMainer @ddyett @peombwa @nikithauc @ramsessanchez @calebkiage @Ndiritu @rkodev @gavinbarron
@@ -0,0 +1,12 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ - package-ecosystem: bundler
9
+ directory: "/"
10
+ schedule:
11
+ interval: daily
12
+ open-pull-requests-limit: 10
@@ -0,0 +1,76 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "master", main ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ "master" ]
20
+ schedule:
21
+ - cron: '41 2 * * 0'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Use only 'java' to analyze code written in Java, Kotlin or both
38
+ # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
39
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
40
+
41
+ steps:
42
+ - name: Checkout repository
43
+ uses: actions/checkout@v3
44
+
45
+ # Initializes the CodeQL tools for scanning.
46
+ - name: Initialize CodeQL
47
+ uses: github/codeql-action/init@v2
48
+ with:
49
+ languages: ${{ matrix.language }}
50
+ # If you wish to specify custom queries, you can do so here or in a config file.
51
+ # By default, queries listed here will override any specified in a config file.
52
+ # Prefix the list here with "+" to use these queries and those in the config file.
53
+
54
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
55
+ # queries: security-extended,security-and-quality
56
+
57
+
58
+ # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
59
+ # If this step fails, then you should remove it and run the build manually (see below)
60
+ - name: Autobuild
61
+ uses: github/codeql-action/autobuild@v2
62
+
63
+ # ℹ️ Command-line programs to run using the OS shell.
64
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
65
+
66
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
67
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
68
+
69
+ # - run: |
70
+ # echo "Run, Build Application using script"
71
+ # ./location_of_script_within_repo/buildscript.sh
72
+
73
+ - name: Perform CodeQL Analysis
74
+ uses: github/codeql-action/analyze@v2
75
+ with:
76
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,34 @@
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: PullRequestConflicting
4
+
5
+ # Controls when the action will run. Triggers the workflow on push or pull request
6
+ # events but only for the master branch
7
+ on:
8
+ push:
9
+ branches: [ main ]
10
+ pull_request:
11
+ types: [synchronize]
12
+ branches: [ main ]
13
+
14
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
15
+ jobs:
16
+ # This workflow contains a single job called "build"
17
+ build:
18
+ # The type of runner that the job will run on
19
+ runs-on: ubuntu-latest
20
+
21
+ # Steps represent a sequence of tasks that will be executed as part of the job
22
+ steps:
23
+ - name: check if prs are dirty
24
+ uses: eps1lon/actions-label-merge-conflict@releases/2.x
25
+ if: env.LABELING_TOKEN != '' && env.LABELING_TOKEN != null
26
+ id: check
27
+ with:
28
+ dirtyLabel: "conflicting"
29
+ repoToken: "${{ secrets.GITHUB_TOKEN }}"
30
+ continueOnMissingPermissions: true
31
+ commentOnDirty: 'This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.'
32
+ commentOnClean: 'Conflicts have been resolved. A maintainer will take a look shortly.'
33
+ env:
34
+ LABELING_TOKEN: ${{secrets.GITHUB_TOKEN }}
@@ -0,0 +1,81 @@
1
+ # This workflow is used to add new issues to GitHub Projects (Beta)
2
+
3
+ name: Add PR to project
4
+ on:
5
+ issues:
6
+ types: [opened]
7
+ jobs:
8
+ track_issue:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: Generate token
12
+ id: generate_token
13
+ uses: tibdex/github-app-token@021a2405c7f990db57f5eae5397423dcc554159c
14
+ with:
15
+ app_id: ${{ secrets.GRAPHBOT_APP_ID }}
16
+ private_key: ${{ secrets.GRAPHBOT_APP_PEM }}
17
+
18
+ - name: Get project data
19
+ env:
20
+ GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
21
+ ORGANIZATION: microsoftgraph
22
+ PROJECT_NUMBER: 38
23
+ run: |
24
+ gh api graphql -f query='
25
+ query($org: String!, $number: Int!) {
26
+ organization(login: $org){
27
+ projectNext(number: $number) {
28
+ id
29
+ fields(first:20) {
30
+ nodes {
31
+ id
32
+ name
33
+ settings
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
39
+
40
+ echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
41
+ echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
42
+ echo 'TRIAGE_OPTION_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="Needs Triage 🔍") |.id' project_data.json) >> $GITHUB_ENV
43
+
44
+ - name: Add Issue to project
45
+ env:
46
+ GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
47
+ ISSUE_ID: ${{ github.event.issue.node_id }}
48
+ run: |
49
+ item_id="$( gh api graphql -f query='
50
+ mutation($project:ID!, $issue:ID!) {
51
+ addProjectNextItem(input: {projectId: $project, contentId: $issue}) {
52
+ projectNextItem {
53
+ id
54
+ }
55
+ }
56
+ }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
57
+
58
+ echo 'ITEM_ID='$item_id >> $GITHUB_ENV
59
+
60
+ - name: Set Triage
61
+ env:
62
+ GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
63
+ run: |
64
+ gh api graphql -f query='
65
+ mutation (
66
+ $project: ID!
67
+ $item: ID!
68
+ $status_field: ID!
69
+ $status_value: String!
70
+ ) {
71
+ set_status: updateProjectNextItemField(input: {
72
+ projectId: $project
73
+ itemId: $item
74
+ fieldId: $status_field
75
+ value: $status_value
76
+ }) {
77
+ projectNextItem {
78
+ id
79
+ }
80
+ }
81
+ }' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.TRIAGE_OPTION_ID }} --silent
@@ -0,0 +1,45 @@
1
+ name: Git Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v[0-9]+.[0-9]+.[0-9]+"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ Git_Release:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ - name: Github Release
15
+ uses: anton-yurchenko/git-release@v5.0
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
18
+ DRAFT_RELEASE: "false"
19
+ PRE_RELEASE: "false"
20
+ CHANGELOG_FILE: "CHANGELOG.md"
21
+ ALLOW_EMPTY_CHANGELOG: "true"
22
+
23
+ deploy_prod:
24
+ environment:
25
+ name: production_feeds
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: '3.1'
32
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
33
+ bundler: 'latest'
34
+ cache-version: 1
35
+ - run: bundle exec rake
36
+ - name: Publish to RubyGems
37
+ run: |
38
+ mkdir -p $HOME/.gem
39
+ touch $HOME/.gem/credentials
40
+ chmod 0600 $HOME/.gem/credentials
41
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
42
+ gem build *.gemspec
43
+ gem push *.gem
44
+ env:
45
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,34 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches: [ main ]
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest]
15
+ ruby-version: ['2.7', '3.0', '3.1', head, jruby, jruby-head, truffleruby, truffleruby-head]
16
+ runs-on: ${{ matrix.os }}
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
23
+ bundler: 'latest'
24
+ cache-version: 1
25
+ - name: Run tests
26
+ run: bundle exec rake
27
+ - name: Upload artifacts for ruby version 3 and ubuntu
28
+ if: ${{ matrix.os == 'ubuntu-latest' && matrix.ruby-version == '3.1'}}
29
+ uses: actions/upload-artifact@v3
30
+ with:
31
+ name: drop
32
+ path: |
33
+ ./Gemfile.lock
34
+ ./README.md
data/.gitignore ADDED
@@ -0,0 +1,58 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ Gemfile.lock
49
+ .ruby-version
50
+ .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
57
+
58
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ ### Changed
13
+
14
+ ## [0.9.0] - 2022-12-30
15
+
16
+ ### Added
17
+
18
+ - Initial public release of the package.
@@ -0,0 +1,9 @@
1
+ # Microsoft Open Source Code of Conduct
2
+
3
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4
+
5
+ Resources:
6
+
7
+ - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8
+ - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9
+ - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
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 all
13
+ 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 THE
21
+ SOFTWARE
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Kiota Http Library for Ruby
2
+
3
+ ![Ruby](https://github.com/microsoft/kiota-http-ruby/actions/workflows/ruby.yml/badge.svg)
4
+
5
+ The Kiota HTTP Library for Ruby is the Ruby HTTP library implementation with [Faraday](https://github.com/lostisland/faraday).
6
+
7
+ A [Kiota](https://github.com/microsoft/kiota) generated project will need a reference to a HTTP package to make HTTP requests to an API endpoint.
8
+
9
+ Read more about Kiota [here](https://github.com/microsoft/kiota/blob/main/README.md).
10
+
11
+ ## Using the http library
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem "microsoft_kiota_http", "0.9.0"
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```shell
22
+ bundle install
23
+ ```
24
+
25
+ Or install it yourself as:
26
+
27
+ ```shell
28
+ gem install microsoft_kiota_http --version "0.9.0"
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ This project welcomes contributions and suggestions. Most contributions require you to agree to a
34
+ Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
35
+ the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
36
+
37
+ When you submit a pull request, a CLA bot will automatically determine whether you need to provide
38
+ a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
39
+ provided by the bot. You will only need to do this once across all repos using our CLA.
40
+
41
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
42
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
43
+ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
44
+
45
+ ## Trademarks
46
+
47
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
48
+ trademarks or logos is subject to and must follow
49
+ [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
50
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
51
+ Any use of third-party trademarks or logos are subject to those third-party's policies.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'bundler/gem_tasks'
6
+ require 'rspec/core/rake_task'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: :spec
data/SECURITY.md ADDED
@@ -0,0 +1,41 @@
1
+ <!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->
2
+
3
+ ## Security
4
+
5
+ Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6
+
7
+ If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8
+
9
+ ## Reporting Security Issues
10
+
11
+ **Please do not report security vulnerabilities through public GitHub issues.**
12
+
13
+ Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14
+
15
+ If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16
+
17
+ You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18
+
19
+ Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
+
21
+ * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22
+ * Full paths of source file(s) related to the manifestation of the issue
23
+ * The location of the affected source code (tag/branch/commit or direct URL)
24
+ * Any special configuration required to reproduce the issue
25
+ * Step-by-step instructions to reproduce the issue
26
+ * Proof-of-concept or exploit code (if possible)
27
+ * Impact of the issue, including how an attacker might exploit the issue
28
+
29
+ This information will help us triage your report more quickly.
30
+
31
+ If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32
+
33
+ ## Preferred Languages
34
+
35
+ We prefer all communications to be in English.
36
+
37
+ ## Policy
38
+
39
+ Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40
+
41
+ <!-- END MICROSOFT SECURITY.MD BLOCK -->
data/SUPPORT.md ADDED
@@ -0,0 +1,25 @@
1
+ # TODO: The maintainer of this repo has not yet edited this file
2
+
3
+ **REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project?
4
+
5
+ - **No CSS support:** Fill out this template with information about how to file issues and get help.
6
+ - **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps.
7
+ - **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide.
8
+
9
+ *Then remove this first heading from this SUPPORT.MD file before publishing your repo.*
10
+
11
+ # Support
12
+
13
+ ## How to file issues and get help
14
+
15
+ This project uses GitHub Issues to track bugs and feature requests. Please search the existing
16
+ issues before filing new issues to avoid duplicates. For new issues, file your bug or
17
+ feature request as a new Issue.
18
+
19
+ For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE
20
+ FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER
21
+ CHANNEL. WHERE WILL YOU HELP PEOPLE?**.
22
+
23
+ ## Microsoft Support Policy
24
+
25
+ Support for this **PROJECT or PRODUCT** is limited to the resources listed above.
@@ -0,0 +1,151 @@
1
+ require 'microsoft_kiota_abstractions'
2
+ require 'faraday'
3
+ require 'net/http'
4
+ require_relative 'kiota_client_factory'
5
+ require_relative 'middleware/response_handler_option'
6
+
7
+ module MicrosoftKiotaFaraday
8
+ class FaradayRequestAdapter
9
+ include MicrosoftKiotaAbstractions::RequestAdapter
10
+
11
+ attr_accessor :authentication_provider, :content_type_header_key, :parse_node_factory, :serialization_writer_factory, :client
12
+
13
+ def initialize(authentication_provider, parse_node_factory=MicrosoftKiotaAbstractions::ParseNodeFactoryRegistry.default_instance, serialization_writer_factory=MicrosoftKiotaAbstractions::SerializationWriterFactoryRegistry.default_instance, client = KiotaClientFactory::get_default_http_client)
14
+
15
+ if !authentication_provider
16
+ raise StandardError , 'authentication provider cannot be null'
17
+ end
18
+ @authentication_provider = authentication_provider
19
+ @content_type_header_key = 'Content-Type'
20
+ @parse_node_factory = parse_node_factory
21
+ if @parse_node_factory.nil?
22
+ @parse_node_factory = MicrosoftKiotaAbstractions::ParseNodeFactoryRegistry.default_instance
23
+ end
24
+ @serialization_writer_factory = serialization_writer_factory
25
+ if @serialization_writer_factory.nil?
26
+ @serialization_writer_factory = MicrosoftKiotaAbstractions::SerializationWriterFactoryRegistry.default_instance
27
+ end
28
+ @client = client
29
+ if @client.nil?
30
+ @client = KiotaClientFactory::get_default_http_client
31
+ end
32
+ @base_url = ''
33
+ end
34
+
35
+ def set_base_url(base_url)
36
+ @base_url = base_url
37
+ end
38
+
39
+ def get_base_url()
40
+ @base_url
41
+ end
42
+
43
+ def get_serialization_writer_factory()
44
+ @serialization_writer_factory
45
+ end
46
+
47
+ def send_async(request_info, factory, errors_mapping)
48
+ raise StandardError, 'request_info cannot be null' unless request_info
49
+ raise StandardError, 'factory cannot be null' unless factory
50
+
51
+ Fiber.new do
52
+ @authentication_provider.authenticate_request(request_info).resume
53
+ request = self.get_request_from_request_info(request_info)
54
+ response = @client.run_request(request.http_method, request.path, request.body, request.headers)
55
+
56
+ response_handler = self.get_response_handler(request_info)
57
+ response_handler.call(response).resume unless response_handler.nil?
58
+ self.throw_if_failed_reponse(response, errors_mapping)
59
+ root_node = self.get_root_parse_node(response)
60
+ root_node.get_object_value(factory)
61
+ end
62
+ end
63
+
64
+ def get_response_handler(request_info)
65
+ option = request_info.get_request_option(MicrosoftKiotaFaraday::Middleware::ResponseHandlerOption::RESPONSE_HANDLER_KEY) unless request_info.nil?
66
+ return option.async_callback unless !option || option.nil?
67
+ end
68
+
69
+ def get_root_parse_node(response)
70
+ raise StandardError, 'response cannot be null' unless response
71
+ response_content_type = self.get_response_content_type(response);
72
+ raise StandardError, 'no response content type found for deserialization' unless response_content_type
73
+ return @parse_node_factory.get_parse_node(response_content_type, response.body)
74
+ end
75
+
76
+ def throw_if_failed_reponse(response, errors_mapping)
77
+ raise StandardError, 'response cannot be null' unless response
78
+
79
+ status_code = response.status;
80
+ if status_code < 400 then
81
+ return
82
+ end
83
+ error_factory = errors_mapping[status_code] unless errors_mapping.nil?
84
+ error_factory = errors_mapping['4XX'] unless !error_factory.nil? || errors_mapping.nil? || status_code > 500
85
+ error_factory = errors_mapping['5XX'] unless !error_factory.nil? || errors_mapping.nil? || status_code < 500 || status_code > 600
86
+ raise MicrosoftKiotaAbstractions::ApiError, 'The server returned an unexpected status code and no error factory is registered for this code:' + status_code.to_s if error_factory.nil?
87
+ root_node = self.get_root_parse_node(response)
88
+ error = root_node.get_object_value(error_factory) unless root_node.nil?
89
+ raise error unless error.nil?
90
+ raise MicrosoftKiotaAbstractions::ApiError, 'The server returned an unexpected status code:' + status_code.to_s
91
+ end
92
+
93
+ def get_request_from_request_info(request_info)
94
+ request_info.path_parameters['baseurl'] = @base_url
95
+ case request_info.http_method
96
+ when :GET
97
+ request = @client.build_request(:get)
98
+ when :POST
99
+ request = @client.build_request(:post)
100
+ when :PATCH
101
+ request = @client.build_request(:patch)
102
+ when :DELETE
103
+ request = @client.build_request(:delete)
104
+ when :OPTIONS
105
+ request = @client.build_request(:options)
106
+ when :CONNECT
107
+ request = @client.build_request(:connect)
108
+ when :PUT
109
+ request = @client.build_request(:put)
110
+ when :TRACE
111
+ request = @client.build_request(:trace)
112
+ when :HEAD
113
+ request = @client.build_request(:head)
114
+ else
115
+ raise StandardError, 'unsupported http method'
116
+ end
117
+ request.path = request_info.uri
118
+ unless request_info.headers.nil? then
119
+ request.headers = Faraday::Utils::Headers.new
120
+ request_info.headers.get_all.select{|k,v|
121
+ if v.kind_of? Array then
122
+ request.headers[k] = v.join(',')
123
+ elsif v.kind_of? String then
124
+ request.headers[k] = v
125
+ else
126
+ request.headers[k] = v.to_s
127
+ end
128
+ }
129
+ end
130
+ request.body = request_info.content unless request_info.content.nil? || request_info.content.empty?
131
+ # TODO the json serialization writer returns a string at the moment, change to body_stream when this is fixed
132
+ request_options = request_info.get_request_options
133
+ if !request_options.nil? && !request_options.empty? then
134
+ request.options = Faraday::RequestOptions.new if request.options.nil?
135
+ request_options.each do |value|
136
+ request.options.context[value.get_key] = value
137
+ end
138
+ end
139
+ request
140
+ end
141
+
142
+ def get_response_content_type(response)
143
+ begin
144
+ response.headers['content-type'].split(';')[0].downcase()
145
+ rescue
146
+ return nil
147
+ end
148
+ end
149
+
150
+ end
151
+ end
@@ -0,0 +1,35 @@
1
+ require 'net/https'
2
+ require 'faraday'
3
+ require_relative 'middleware/parameters_name_decoding_handler'
4
+ module MicrosoftKiotaFaraday
5
+ class KiotaClientFactory
6
+ def self.get_default_middleware()
7
+ return [
8
+ MicrosoftKiotaFaraday::Middleware::ParametersNameDecodingHandler
9
+ ]
10
+ end
11
+
12
+ def self.get_default_http_client(middleware=nil, default_middleware_options=Array.new)
13
+ if middleware.nil? #empty is fine in case the user doesn't want to use any middleware
14
+ middleware = self.get_default_middleware()
15
+ end
16
+ connection_options = Hash.new
17
+ connection_options[:request] = Hash.new
18
+ connection_options[:request][:context] = Hash.new
19
+ unless default_middleware_options.nil? || default_middleware_options.empty? then
20
+ default_middleware_options.each do |value|
21
+ connection_options[:request][:context][value.get_key] = value
22
+ end
23
+ end
24
+ conn = Faraday::Connection.new(nil, connection_options) do |builder|
25
+ builder.adapter Faraday.default_adapter
26
+ builder.ssl.verify = true
27
+ builder.ssl.verify_mode = OpenSSL::SSL::VERIFY_PEER
28
+ middleware.each do |handler|
29
+ builder.use handler
30
+ end
31
+ end
32
+ conn
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ require 'faraday'
2
+ require_relative 'parameters_name_decoding_option'
3
+ module MicrosoftKiotaFaraday
4
+ module Middleware
5
+ class ParametersNameDecodingHandler < Faraday::Middleware
6
+ @@default_option = ParametersNameDecodingOption.new
7
+ def call(request_env)
8
+ request_option = request_env[:request][:context][@@default_option.get_key] unless request_env[:request].nil? || request_env[:request][:context].nil?
9
+ request_option = @@default_option if request_option.nil?
10
+ unless request_env[:url].nil? || !request_option.enabled || request_option.characters_to_decode.nil? || request_option.characters_to_decode.empty? then
11
+ request_url = request_env[:url].to_s
12
+ request_option.characters_to_decode.each do |character|
13
+ request_url = request_url.gsub(get_regex_for_character(character), character)
14
+ end
15
+ request_env[:url] = URI.parse(request_url)
16
+ end
17
+ @app.call(request_env) unless @app.nil?
18
+ end
19
+
20
+ def get_regex_for_character(character)
21
+ @regex_cache ||= Hash.new
22
+ if @regex_cache[character].nil? then
23
+ @regex_cache[character] = Regexp.new("%#{character.ord.to_s(16)}", true)
24
+ end
25
+ return @regex_cache[character]
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ require 'microsoft_kiota_abstractions'
3
+ module MicrosoftKiotaFaraday
4
+ module Middleware
5
+ class ParametersNameDecodingOption
6
+ include MicrosoftKiotaAbstractions::RequestOption
7
+ attr_accessor :enabled, :characters_to_decode
8
+
9
+ def initialize(enabled = true, characters_to_decode = ['$', '.', '-', '~'])
10
+ @enabled = enabled
11
+ @characters_to_decode = characters_to_decode
12
+ end
13
+
14
+ def get_key()
15
+ "parametersNameDecoding"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ require 'microsoft_kiota_abstractions'
3
+ module MicrosoftKiotaFaraday
4
+ module Middleware
5
+ class ResponseHandlerOption
6
+ RESPONSE_HANDLER_KEY = "responseHandler"
7
+ # a lambda that takes the native response type and returns a Fiber with a MicrosoftKiotaAbstractions::Parsable
8
+ attr_accessor :async_callback
9
+ def get_key()
10
+ RESPONSE_HANDLER_KEY
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MicrosoftKiotaFaraday
4
+ VERSION = '0.9.0'
5
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'microsoft_kiota_faraday/version'
4
+ require_relative 'microsoft_kiota_faraday/middleware/response_handler_option'
5
+ require_relative 'microsoft_kiota_faraday/middleware/parameters_name_decoding_option'
6
+ require_relative 'microsoft_kiota_faraday/middleware/parameters_name_decoding_handler'
7
+ require_relative 'microsoft_kiota_faraday/kiota_client_factory'
8
+ require_relative 'microsoft_kiota_faraday/faraday_request_adapter'
9
+
10
+ module MicrosoftKiotaFaraday
11
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/microsoft_kiota_faraday/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "microsoft_kiota_faraday"
7
+ spec.version = MicrosoftKiotaFaraday::VERSION
8
+ spec.authors = 'Microsoft Corporation'
9
+ spec.email = 'graphsdkpub@microsoft.com'
10
+ spec.description = 'Kiota HttpCore implementation with Faraday'
11
+ spec.summary = "Microsoft Kiota Faraday - Kiota Ruby http request adapter for running requests"
12
+ spec.homepage = 'https://microsoft.github.io/kiota/'
13
+ spec.license = 'MIT'
14
+ spec.metadata = {
15
+ 'bug_tracker_uri' => 'https://github.com/microsoft/kiota-http-ruby/issues',
16
+ 'changelog_uri' => 'https://github.com/microsoft/kiota-http-ruby/blob/main/CHANGELOG.md',
17
+ 'homepage_uri' => spec.homepage,
18
+ 'source_code_uri' => 'https://github.com/microsoft/kiota-http-ruby',
19
+ 'github_repo' => 'ssh://github.com/microsoft/kiota-http-ruby'
20
+ }
21
+ spec.required_ruby_version = ">= 2.7.0"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = 'bin'
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+ spec.add_runtime_dependency 'microsoft_kiota_abstractions', '~> 0.12.0', '>= 0.12.0'
32
+ spec.add_runtime_dependency 'faraday', '~> 2.7', '>= 2.7.2'
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ spec.add_development_dependency 'rubocop'
36
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: microsoft_kiota_faraday
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Microsoft Corporation
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: microsoft_kiota_abstractions
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.12.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 0.12.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.12.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.7'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.7.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.7'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.7.2
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '13.0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '13.0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '3.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rubocop
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ description: Kiota HttpCore implementation with Faraday
96
+ email: graphsdkpub@microsoft.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - ".github/CODEOWNERS"
102
+ - ".github/dependabot.yml"
103
+ - ".github/workflows/code-ql.yml"
104
+ - ".github/workflows/conflicting-pr-label.yml"
105
+ - ".github/workflows/projectsbot.yml"
106
+ - ".github/workflows/release.yml"
107
+ - ".github/workflows/ruby.yml"
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - CHANGELOG.md
111
+ - CODE_OF_CONDUCT.md
112
+ - Gemfile
113
+ - LICENSE
114
+ - README.md
115
+ - Rakefile
116
+ - SECURITY.md
117
+ - SUPPORT.md
118
+ - lib/microsoft_kiota_faraday.rb
119
+ - lib/microsoft_kiota_faraday/faraday_request_adapter.rb
120
+ - lib/microsoft_kiota_faraday/kiota_client_factory.rb
121
+ - lib/microsoft_kiota_faraday/middleware/parameters_name_decoding_handler.rb
122
+ - lib/microsoft_kiota_faraday/middleware/parameters_name_decoding_option.rb
123
+ - lib/microsoft_kiota_faraday/middleware/response_handler_option.rb
124
+ - lib/microsoft_kiota_faraday/version.rb
125
+ - microsoft_kiota_faraday.gemspec
126
+ homepage: https://microsoft.github.io/kiota/
127
+ licenses:
128
+ - MIT
129
+ metadata:
130
+ bug_tracker_uri: https://github.com/microsoft/kiota-http-ruby/issues
131
+ changelog_uri: https://github.com/microsoft/kiota-http-ruby/blob/main/CHANGELOG.md
132
+ homepage_uri: https://microsoft.github.io/kiota/
133
+ source_code_uri: https://github.com/microsoft/kiota-http-ruby
134
+ github_repo: ssh://github.com/microsoft/kiota-http-ruby
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: 2.7.0
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubygems_version: 3.3.26
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Microsoft Kiota Faraday - Kiota Ruby http request adapter for running requests
154
+ test_files: []