Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ID is required to invoke public resource.Metadata$Service.getId() #53

Open
acamacho82 opened this issue May 25, 2018 · 1 comment
Open

Comments

@acamacho82
Copy link
Contributor

The Metadata service returns IllegalStateException error when calling to the methods getId(), getHostname(), etc.

java.lang.IllegalStateException: ID is required to invoke public abstract java.lang.Long com.softlayer.api.service.resource.Metadata$Service.getId()

Following code can be used to reproduce the issue.

public class TestMetadata {

    public static void main(String arg[]){
        String privateEndPoint = "https://api.service.softlayer.com/rest/v3/";
        ApiClient client = new RestApiClient(privateEndPoint);

        Metadata.Service metadataService = Metadata.service(client);

        try {            
            long id = metadataService.getId();            
            System.out.println("This VSI ID is " + id);            
        } catch (Exception e) {            
            System.out.println("SoftlayerMetadata error in " + e);
        }
    }
}

The problem is because the Metadata java class has set instanceRequired = true in all methods.

        @ApiMethod(instanceRequired = true)
        public Long getId();

Workaround
I created my own Metadata java class and I set instanceRequired = false

@cretz
Copy link
Contributor

cretz commented Jun 21, 2018

The better fix is probably to update the metadata generator that dumps https://api.softlayer.com/metadata/v3.1 (careful, big JSON) to set static to true on methods for SoftLayer_Resource_Metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants