Coder Social home page Coder Social logo

ya-client's Introduction

ya-client's People

Contributors

etam avatar evik42 avatar grisha87 avatar kamirr avatar maaktweluit avatar mateuszsrebrny avatar mfranciszkiewicz avatar mrdarthshoe avatar nieznanysprawiciel avatar omeg avatar pnowosie avatar pociej avatar prekucki avatar pwalski avatar scx1332 avatar sewerynkras avatar staszek-krotki avatar stranger80 avatar tworec avatar wiezzel avatar wkargul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ya-client's Issues

Progress Reporting

  • extend ExeScriptCommandResult with filed for progress reporting for deploy & transfer.
  • extend deploy & transfer command with progress option.

Base URLs are truncated to the last '/'

Base URLs for yagna APIs specified in the command line or via environment vars are truncated to the last '/', which may lead to confusing agent behaviour.

For example, with the environment variable YAGNA_MARKET_URL set to http://127.0.0.1:5001/market-api/v1" the agent will use just http://127.0.0.1:5001/market-api/`, without the trailing v1 as the base URL which will lead to errors.

This happens because of the Url::join method from the url crate treats v1 above as referring to a file:

use url::{Url, ParseError};

fn test() -> Result<(),ParseError> {

    let base_url_str = "http://0.0.0.0:6000/market-api/v1";
    {
        let base_url = Url::parse(base_url_str)?;
        let url = base_url.join("operation")?;
        assert_eq!(url.as_str(), "http://0.0.0.0:6000/market-api/operation");
    }
    {
        let base_url = Url::parse(&format!("{}/", base_url_str))?;
        let url = base_url.join("operation")?;
        assert_eq!(url.as_str(), "http://0.0.0.0:6000/market-api/v1/operation");
    }
    Ok(())
}

I think all base URLs that are not terminated with "/" should have the '/' character appended.

Support non-default configuration for Payment API

Currently only default configuration can be used because ProviderApiConfig and RequestorApiConfig have private fields and no constructor. Preferred manner for handling this is:

  1. Implement a config builder class so that only non-default config values need to be specified.
  2. Implement a function which reads config values from environment variables.

Request body with message should be required in terminate agreement

API: Market
Endpoint: POST /agreements/{agreementId}/terminate (on both provider and requestor APIs)

For the above endpoint, only agreementId parameter is marked as required in the API spec. Request body is marked as optional (and is generated as such). However, using this endpoint I found out that the request body is required and must include a message field.

Otherwise, the server returns a 400 with either Json deserialize error: EOF while parsing a value at line 1 column 0 or Json deserialize error: missing field message at line 1 column 2, depending on whether we pass an empty request body or not.

Required attributes, defaults, typing

I don't really know ya-client so I'm not sure how to state the issue correctly and what really needs fixing here.

Nevertheless, let's take a look for example at ya_market.models.proposal.Proposal and the proposal_id attribute (other Proposal attributes and other classes have similar "problems"):

class Proposal(object):
    openapi_types = { 
        'proposal_id': 'str',
    }   
        
    attribute_map = {
        'proposal_id': 'proposalId',
    }       
        
    def __init__(self, properties=None, constraints=None, proposal_id=None, issuer_id=None, state=None, timestamp=None, prev_proposal_id=None, local_vars_configuration=None):  # noqa: E501   
        self._proposal_id = None
        self.proposal_id = proposal_id
        
   @property
   def proposal_id(self):
       return self._proposal_id

   @proposal_id.setter
   def proposal_id(self, proposal_id):
       if self.local_vars_configuration.client_side_validation and proposal_id is None:  # noqa: E501
           raise ValueError("Invalid value for `proposal_id`, must not be `None`")  # noqa: E501

       self._proposal_id = proposal_id

All of this together adds up to "If we have self.local_vars_configuration.client_side_validation then proposal_id is required and must not be None".

So the main question is - what is this self.local_vars_configuration.client_side_validation & do we really need an option to initialize a Proposal without proposal_id? Because there is a cost behind such construction: static type checkers are not clever enough to understand this. So e.g. writing:

class OfferProposal(object):
    def __init__(self, subscription: "Subscription", proposal: models.ProposalEvent):
        self._proposal: models.ProposalEvent = proposal

    @property
    def id(self) -> str:
        return self._proposal.proposal.proposal_id

makes mypy sad:

Incompatible return value type (got "Optional[str]", expected "str")

--> it would be nice to somehow improve the typing here.

Findings from using swagger-gen

While working on the requestor agent for the python integration tests i found some improvements to the swagger files:

Collect events timeout optional value unspecified

Collect events can have optional timeout. It is unspecified what happens if timeout is not set.
I would assume it means 0 timeout, and call should return immediately.
Probably we should mention this in spec.

Check specs/common.yaml file

url_format! causes compiler warning since 1.64.0

Warning: named_arguments_used_positionally
Triggered by: url_format!("{}", arg);
Why: Macro expansion changes all arguments into named ones, and Rust warns about positional uses of named macros since 1.64.0.

Move swagger python client generation to ya-client

For the yagna-integration level 1 project i have generated the swagger models and client side library.

It seems they belong in the ya-client repository, next to the rust models.

  • Move the model files, client api and readme files about generation to ya-client
  • Add auto generation / validation ( generate with [email protected] ) and apply 3 git patches in a github job

Agreement Events serves to serve as audit log for Agreement

We agreed that agreement events serves a purpose of audit log for Agreement.
It is to be decided how to present this log/history for particular Agreement. Possibilities that we see:

  • support filtering collectAgreementEvents by agreementId
  • extend getAgreement endpoint to contain related events or at least termination reason.
  • create new endpoint for getting agreement history

Originally posted by @tworec in #61 (comment)

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.