Git Product home page Git Product logo

ps-ovhapi's Introduction

ps-ovhapi

Powershell helper to acces OVH REST API https://api.ovh.com

Requirements

Limitations :

  • credentials request in Get-OvhApiCredential is hard coded to allow GET on /*
  • Only one api credentials at a time (stored in script scope)
  • body for PUT and POST has to be in json

Usage :

import-module ovh-api.psm1
# Create credentials 
Connect-OvhApi -ak '<ak>' -as '<as>' -ck 'fake ck'
Get-OvhApiCredential

# API access (returns Powershell objects)
Connect-OvhApi -ak '<ak>' -as '<as>' -ck '<ck>'
Invoke-OvhApi -query "/cloud"
Invoke-OvhApi -method PUT -query "/cloud/..." -body "{ nice : json }"

# shortcuts for rest methods
Invoke-OvhApi GET /cloud
Get-OvhApi /cloud

Invoke-OvhApi PUT  "/cloud/..." -body "{ nice : json }"
New-OvhAPI  "/cloud/..." -body "{ nice : json }"

Invoke-OvhApi POST  "/cloud/..." -body "{ nice : json }"
Set-OvhAPI  "/cloud/..." -body "{ nice : json }"

Invoke-OvhApi DELETE  "/cloud/..."
Remove-OvhAPI  "/cloud/..."

# Returning raw json
Invoke-OvhApi -method GET -query "/cloud" -raw

# more complex :
# get servers, extracts logical and physical data
Get-OvhApi /dedicated/server | %{ Get-OvhApi /dedicated/server/$_ } | select name, reverse, datacenter, rack 

ps-ovhapi's People

Contributors

ghoz avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ps-ovhapi's Issues

Mise à jour ?

Bonjour,
je m'interresse beaucoup à votre API, mais lorsque j'essaie de l'utiliser, j'ai un message d'erreur.
J'ai pourtant bien créer un compte OVH, une application. Pouvez-vous m'aider, ou vérifier que votre API est toujours à jour ?

clear
Connect-OvhApi -ak 'aaa' -as 'zzz' -ck 'xxx'
Get-OvhApiCredential
Invoke-OvhApi -query "/domain"

Invoke-OvhApi GET /domain
Error: 403.
{"errorCode":"NOT_CREDENTIAL","httpCode":"403 Forbidden","message":"This credential does not exist"}
At C:\Users\visimic\Desktop\API.ps1:273 char:11

  •       Throw "Invoke-OvhApi $method $query`nError: $status.`n$Rep"
    
  •       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Invoke-OvhApi G...oes not exist"}:String) [], RuntimeException
    • FullyQualifiedErrorId : Invoke-OvhApi GET /domain
      Error: 403.
      {"errorCode":"NOT_CREDENTIAL","httpCode":"403 Forbidden","message":"This credential does not exist"}

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.