GithubHelp home page GithubHelp logo

laravel-gitlab's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

laravel-gitlab's Issues

Usage with GitLab\ResultPager

We recently crossed the threshold of 100 projects, which is the maximum amount of items the GitLab API will return at once. In order to fetch all results, I have discovered that the base PHP GitLab API library exposes a mechanism to page over all results: https://github.com/GitLabPHP/Client#example-with-pager

How can this be used with this package? My guess is that I would have to get the underlying client instance like this:

/** @var \GrahamCampbell\GitLab\GitLabManager $gitLabManager */

$pager = new \GitLab\ResultPager($gitLabManager->connection());

I propose that we either:

  • document this usage
  • add a helper method pager(): \GitLab\ResultPager to \GrahamCampbell\GitLab\GitLabManager

Open for better suggestions, of course.

Set oauth dynamically by logged in user

Hello,

i've try delete user either from projects or from group. but always get 404 not found.

$project = Gitlab::Projects()->show($projectId);
$projectPermissions = $project['permissions'];
$groupId = $project['namespace']['parent_id'];

 if ( empty($projectPermissions['project_access']) && !empty($projectPermissions['group_access'])) {
                
                // delete from group member
                try {
                    Gitlab::Groups()->removeMember($groupId, $userId);
                    $removed[] = "remove user id : " . $userId . " from group id : " . $projectId;
                } catch(\Exception $e) {
                    $removed[] =  $e->getMessage(); 
                }
 } else if ( empty($projectPermissions['group_access']) && !empty($projectPermissions['project_access'])) {
                //delete from project member
                try {
                    Gitlab::Projects()->removeMember($projectId, $userId);
                    $removed[] = "remove user id : " . $userId . " from project id : " . $projectId;
                } catch(\Exception $e) {
                    $removed[] = $e->getMessage();
                    
                }
            }

i try curl also
Screenshot_20200903_163017_edit

is it permission problem?, then i found the second problem.

i've been read the docs, but i don't now how to set oauth dynamic by user or is it possible, or maybe i have wrong logic in my mind?

i have a case user login via oauth token, and use the token from logged in user oauth token for accessing gitlab repo.
so by those token we can use it as for managing repo.
my problem is every user login and the app still use my user as a basis. so even the project owner or group owner can't delete member. the error says 404.
i've been set the connection in config/gitlab.php

'connections' => [

        'main' => [
            'token'   => i set this with my private token',
            'method'  => 'token',
        ],

        'alternative' => [
            'token'   => 'your-token', <- how to set this dynamically by logged in user after redirect callback
            'method'  => 'oauth',
        ],

    ],

how to set oauth token dynamically?

if been try

       $client = Gitlab::authenticate($getInfo->token, 'oauth_token');

still not work.

thank you for your answer.

Limits is set to 20 for each request?

Hi @GrahamCampbell – thanks for the project.

$projects = GitLab::projects()->all();
For this request I get is an array with 20 elements only – is it limited? It should be clearly more than that.
Same groups, Issues, mergeRequests, namespaces and users

Am I missing something?

Thank you.

Cannot unpack array with string keys

I updated the package from 3.3 to 4.0 and I get the error:

Cannot unpack array with string keys

 at C:\dev\domains\tunnel\vendor\m4tthumphrey\php-gitlab-api\src\ResultPager.php:81
     77▕      * @return array
     78▕      */
     79▕     public function fetch(ApiInterface $api, string $method, array $parameters = [])
     80▕     {
  ➜  81▕         $result = $api->perPage($this->perPage)->$method(...$parameters);
     82▕
     83▕         if (!\is_array($result)) {
     84▕             throw new RuntimeException('Pagination of this endpoint is not supported.');
     85▕         }

  1   C:\dev\domains\tunnel\vendor\m4tthumphrey\php-gitlab-api\src\ResultPager.php:122
      Gitlab\ResultPager::fetch(Object(Gitlab\Api\Projects), "hooks", [])

  2   [internal]:0
      Gitlab\ResultPager::fetchAllLazy(Object(Gitlab\Api\Projects), "hooks", [])

Versions

package in composer installed version
php ^7.3 7.4.12
composer --- 2.0.6
graham-campbell/gitlab ^4.0 4.0.0
m4tthumphrey/php-gitlab-api --- 10.0.2
"require": {
    "php": "^7.3",
    "fideloper/proxy": "^4.3",
    "fruitcake/laravel-cors": "^2.0",
    "graham-campbell/gitlab": "^4.0",
    "guzzlehttp/guzzle": "^7.0",
    "laravel/framework": "^8.7",
    "laravel/slack-notification-channel": "^2.2",
    "http-interop/http-factory-guzzle": "^1.0"
},

There are no such problems in version 3.3 of graham-campbell/gitlab.

Ease the usage of webhooks

I saw this was discussed previously in #16. It is true that webhook usage is not hard, although this library could make it easier by adding a clear path on how it can be implemented.

The controller method you suggested in #16 (comment) seems like a great idea. Are you open to adding that into the library, together with a bit of documentation around how to use it?

Ideas for further improvement:

  • Have separate events for each webhook type
  • Add a small testing helper

I would be willing to provide a PR.

Wait for a fork to complete

Hello, I'm trying to execute actions after a fork is completed, but can't find a way of waiting for the call to complete.

I want to do this:

$fork = GitLab::projects()->fork($original['id'], [
    'namespace' => trim($destino, '/'),
    'name' => $nombre,
    'path' => Str::slug($ruta)
]);

// Desconectarlo del repositorio original
GitLab::projects()->removeForkRelation($fork['id']);

Is there any way of doing this?

Thank you in advance for your help.

Creating issues in a project

How do I create an issue with this package?
I can retrieve the correct project as an array, but it shows as an array, rather than \Gitlab\Models\Project. so I can't call the createIssue method.

I retrieved the project like this. because there wasn't a "find by id" either. at least not from what I could see in the documentation.

collect($this->manager->projects()->all())->firstWhere('id', $projectId)

Thanks

SSL path for Guzzle

Guzzle, and thereby curl do not like SSL domains being accessed that aren't known Certificate Authorities.

In the past I could do this:

$options = [
	'verify' => '/var/www/laravel/storage/certs/UserTrust.pem',
];

$client = new \GuzzleHttp\Client();

$client->get('https://randomssldomain.com', $options);

How could I add the 'verify' flag to the underlying Guzzle6 adapter configuration to use your library?

Gitlab Webhooks

Are gitlab webhooks supported by the library?
If not are there any plans to add support in future?

No option to get a merge request's pipelines

in the gitlab Api we can get a merge request's pipelines (in order to know the MR's build status for example)
Something like this in "MergeRequests.php":

` /**

 * @param int $project_id

 * @param int $mr_id

 * @return mixed

 */

public function pipelines($project_id, $mr_id)
{

    return $this->get($this->getProjectPath($project_id, 'merge_requests/'.
  $this->encodePath($mr_id).'/pipelines'));

}

`

Retreiwving Projects

Hi, I apologise if this is a dumb question!
I call am using this code

<?php

namespace App\Http\Controllers\API\Integrations\GitLab;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use GrahamCampbell\GitLab\Facades\GitLab;
use GrahamCampbell\GitLab\GitLabManager;

class GitLabsController extends Controller
{

    function __construct() {
		 }




public function index(){
   

$projects = GitLab::Projects();
 return response()->json($projects);

}
}

in my controller (I have put my access token in the config settings)
but its returning an empty array,
Can you advise what I am doing wrong?

Dynamic configuration

Hello,
I am creating a project that users can add their tokens to read their projects to distribute packages like packagist does but for gitlab CI/CD.

But I don't see how I can do it since I only see that to add the token, you have to add it in config/gitlab.php

   'main' => [
             'token' => 'your-token',
             'method' => 'token',
]

Is there a way to customize the token and domain by code?

Thank you.

ResultPager issue

Hi guys.

I have an issue with ResultPager, My code goes like this:

$client = new Client();
$pager = new ResultPager($client,20);
$issues = $pager->fetchAll($client->repositories(), 'commits', [11261183]);

and get back with the response array of all 700 commits not paged :(

Am I doing something wrong? Please help with this issue. Pagination is a must in my implementation of API.

Self hosted Gitlab

We've recently switched to this package for working with the Gitlab API. But it seems that this package is not really designed to use with a self hosted Gitlab instance? There is no configuration where we can specify our Gitlab URL. Only thing we can do is use the ->setUrl() method everytime, this doesn't really seem like a nice solution.

Am I missing some configuration step?

Guzzle client build error

Hi firstly thanks for dealing with my last issue so rapidly. Sadly after successfully installing the package and registering the service provider and alias as well as creating and configuring the git-lab config file I am now getting the following error.

error

I have gone down the rabbit hole for a while and I think its losing the config at some point. Or that i have done some sort of rookie mistake :) .

Need to update project due to Framework update

Hi i have recently tried to install your package, however a new dependency on Laravel called Nexmo seems to be conflicting with your composer require. Any help would be appreciated.

'all()' methods do not seem to fetch all from API

My apologies if I've missed this functionality, but I don't see how to make the all() methods return paged results from the GitLab API. The php-gitlab-api project provides a ResultPager class which fetches all pages, but that does not appear to be used.

For example, this fetches only the first page of my projects:

$projectData = $this->gitLabManager->projects()->all();

I can explicitly use a pager to get all:

$client = $this->gitLabManager->connection();
$pager = new \Gitlab\ResultPager($client);
$projectData = $pager->fetchAll($client->api('projects'),'all');

Is there a way to have the all() method do the same?

Oauth, successfully generating a token, fails with 401 unauthorized when making a call to gitlab api.

I have the following routes as oauth callback and redirect.

Route::get('/oauth', function () {
    return Socialite::driver('gitlab')->redirect();
});

Route::get('/redirect', function () {
    $user = Socialite::driver('gitlab')->user();
    var_dump($user->token);
   return redirect('/')->withCookie(cookie('token', $user->token, 15));
});

Route::get('/', function () {
    $projects = GitLab::Projects()->all();
    dd($projects);
});

I can check the token and verify that an oauth token is being provided after login, but then, I get a 401 unauthorized when I make the projects call.

gitlab.php config is as follows: 
        'main' => [
            'token'   => $_COOKIE['token'],
            'method'  => 'oauth',
            // 'backoff' => false,
            // 'cache'   => false,
            // 'sudo'    => null,
             'url'     => 'http://git.org.com/api/v4/',
        ],

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.